From tismer at centera.de Thu Jun 3 19:25:19 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 19:25:19 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core slp_transfer.c, 1.24, 1.25 stacklesseval.c, 1.153, 1.154 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv15407/Stackless/core Modified Files: slp_transfer.c stacklesseval.c Log Message: moved more things into slp_transfer.c, to prevend inlining and optimization (gcc 3.3.2 problem) Index: slp_transfer.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/slp_transfer.c,v retrieving revision 1.24 retrieving revision 1.25 diff -C2 -d -r1.24 -r1.25 *** slp_transfer.c 3 Jun 2004 17:18:06 -0000 1.24 --- slp_transfer.c 3 Jun 2004 17:25:17 -0000 1.25 *************** *** 46,50 **** #include "platf/slp_platformselect.h" ! /* this function must be here, too, to prevend inlining */ static int --- 46,70 ---- #include "platf/slp_platformselect.h" ! /* these functions must be here, too, to prevend inlining */ ! ! int ! slp_cstack_save(PyCStackObject *cstprev) ! { ! int stsizeb = (cstprev)->ob_size * sizeof(int*); ! ! memcpy((cstprev)->stack, (cstprev)->startaddr - ! (cstprev)->ob_size, stsizeb); ! return stsizeb; ! } ! ! void ! slp_cstack_restore(PyCStackObject *cst) ! { ! cst->tstate->st.nesting_level = cst->nesting_level; ! /* mark task as no longer responsible for cstack instance */ ! cst->task = NULL; ! memcpy(cst->startaddr - cst->ob_size, &cst->stack, ! (cst->ob_size) * sizeof(int*)); ! } static int Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.153 retrieving revision 1.154 diff -C2 -d -r1.153 -r1.154 *** stacklesseval.c 3 Jun 2004 17:18:06 -0000 1.153 --- stacklesseval.c 3 Jun 2004 17:25:17 -0000 1.154 *************** *** 125,148 **** } ! int ! slp_cstack_save(PyCStackObject *cstprev) ! { ! int stsizeb = (cstprev)->ob_size * sizeof(int*); ! ! memcpy((cstprev)->stack, (cstprev)->startaddr - ! (cstprev)->ob_size, stsizeb); ! return stsizeb; ! } ! ! void ! slp_cstack_restore(PyCStackObject *cst) ! { ! cst->tstate->st.nesting_level = cst->nesting_level; ! /* mark task as no longer responsible for cstack instance */ ! cst->task = NULL; ! memcpy(cst->startaddr - cst->ob_size, &cst->stack, ! (cst->ob_size) * sizeof(int*)); ! } ! static char cstack_doc[] = --- 125,129 ---- } ! /* slp_cstack_save/restore moved to slp_transfer */ static char cstack_doc[] = _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 14:23:15 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 14:23:15 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/module scheduling.c, 1.101, 1.102 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/module In directory centera.de:/tmp/cvs-serv6764/Stackless/module Modified Files: scheduling.c Log Message: oops, forgot to remove a breakpoint :-)) Index: scheduling.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/scheduling.c,v retrieving revision 1.101 retrieving revision 1.102 diff -C2 -d -r1.101 -r1.102 *** scheduling.c 3 Jun 2004 12:19:14 -0000 1.101 --- scheduling.c 3 Jun 2004 12:23:13 -0000 1.102 *************** *** 333,337 **** int ret; \ if (ts->st.schedlock) { \ - { __asm int 3} \ RUNTIME_ERROR( \ "Recursive scheduler call due to callbacks!", \ --- 333,336 ---- _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:03:45 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:03:45 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Include descrobject.h, 1.2, 1.3 object.h, 1.10, 1.11 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Include In directory centera.de:/tmp/cvs-serv3004/Include Modified Files: descrobject.h object.h Log Message: Stackless 3.1 almost ready. All tests are working, both Python and Stackless, both soft and hard switching. New features: channels are working cross-thread! Stack protection for eval_frame and pickling is complete. A couple of smallish features are missing: pickling of channels refuse running tasklets from foreign threads channel.transfer scheduling strategy cross-thread cframe pickling, get rid of invalid_exec funcs, instead use the missing cframe owner-tasklet pointer! add more tests! Index: descrobject.h =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Include/descrobject.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** descrobject.h 25 Mar 2004 22:59:07 -0000 1.2 --- descrobject.h 2 Jun 2004 23:03:42 -0000 1.3 *************** *** 29,32 **** --- 29,35 ---- wrapperfunc wrapper; char *doc; + #ifdef STACKLESS + int slp_offset; + #endif int flags; PyObject *name_strobj; *************** *** 36,43 **** #define PyWrapperFlag_KEYWORDS 1 /* wrapper function takes keyword args */ - #ifdef STACKLESS - #define PyWrapperFlag_STACKLESS 2 - #endif - /* Various kinds of descriptor objects */ --- 39,42 ---- *************** *** 70,73 **** --- 69,75 ---- struct wrapperbase *d_base; void *d_wrapped; /* This can be any function pointer */ + #ifdef STACKLESS + int d_slpmask; + #endif } PyWrapperDescrObject; Index: object.h =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Include/object.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** object.h 25 Mar 2004 22:59:07 -0000 1.10 --- object.h 2 Jun 2004 23:03:42 -0000 1.11 *************** *** 5,8 **** --- 5,11 ---- #endif + #ifdef STACKLESS + #include "core/slp_exttype.h" + #endif /* Object and type object interface */ *************** *** 325,331 **** --- 328,356 ---- struct _typeobject *tp_next; #endif + #ifdef STACKLESS + /* we need the extended strucutre right here */ + PyNumberMethods as_number; + PyMappingMethods as_mapping; + PySequenceMethods as_sequence; /* as_sequence comes after as_mapping, + so that the mapping wins when both + the mapping and the sequence define + a given operator (e.g. __getitem__). + see add_operators() in typeobject.c . */ + PyBufferProcs as_buffer; + PyObject *name, *slots; + slp_methodflags slpflags; + #endif } PyTypeObject; + #ifdef STACKLESS + + /* in Stackless, this is just a synonym */ + #define PyHeapTypeObject PyTypeObject + + #define PyHeapType_GET_MEMBERS(etype) \ + ((PyMemberDef *)(((char *)etype) + (etype)->ob_type->tp_basicsize)) + #else + /* The *real* layout of a type object when allocated on the heap */ typedef struct _heaptypeobject { *************** *** 349,352 **** --- 374,378 ---- ((PyMemberDef *)(((char *)etype) + (etype)->type.ob_type->tp_basicsize)) + #endif /* Generic type check */ *************** *** 491,495 **** /* These two bits are preserved for Stackless Python, next after this is 16 */ #ifdef STACKLESS ! #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (3L<<15) #else #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 --- 517,522 ---- /* These two bits are preserved for Stackless Python, next after this is 16 */ #ifdef STACKLESS ! #define Py_TPFLAGS_HAVE_STACKLESS_CALL (1L<<15) ! #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION (1L<<16) #else #define Py_TPFLAGS_HAVE_STACKLESS_EXTENSION 0 *************** *** 504,507 **** --- 531,535 ---- Py_TPFLAGS_HAVE_ITER | \ Py_TPFLAGS_HAVE_CLASS | \ + Py_TPFLAGS_HAVE_STACKLESS_EXTENSION | \ 0) _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:03:46 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:03:46 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core stackless_impl.h, 1.89, 1.90 stacklesseval.c, 1.150, 1.151 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv3004/Stackless/core Modified Files: stackless_impl.h stacklesseval.c Log Message: Stackless 3.1 almost ready. All tests are working, both Python and Stackless, both soft and hard switching. New features: channels are working cross-thread! Stack protection for eval_frame and pickling is complete. A couple of smallish features are missing: pickling of channels refuse running tasklets from foreign threads channel.transfer scheduling strategy cross-thread cframe pickling, get rid of invalid_exec funcs, instead use the missing cframe owner-tasklet pointer! add more tests! Index: stackless_impl.h =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stackless_impl.h,v retrieving revision 1.89 retrieving revision 1.90 diff -C2 -d -r1.89 -r1.90 *** stackless_impl.h 24 May 2004 01:05:17 -0000 1.89 --- stackless_impl.h 2 Jun 2004 23:03:43 -0000 1.90 *************** *** 26,35 **** */ - /* extract the lower bit of Py_TPFLAGS_HAVE_STACKLESS_EXTENSION */ - - #define Py_TPFLAGS_HAVE_STACKLESS_CALL \ - (Py_TPFLAGS_HAVE_STACKLESS_EXTENSION & \ - (Py_TPFLAGS_HAVE_STACKLESS_EXTENSION >> 1)) - /******************************************************************** * --- 26,29 ---- *************** *** 109,113 **** PyAPI_FUNC(struct _frame *) slp_ensure_new_frame(struct _frame *f); ! /* exposing the generator type */ PyAPI_DATA(PyTypeObject) PyGenerator_Type; --- 103,107 ---- PyAPI_FUNC(struct _frame *) slp_ensure_new_frame(struct _frame *f); ! /* exposing some hidden types */ PyAPI_DATA(PyTypeObject) PyGenerator_Type; *************** *** 116,120 **** #define PyGenerator_Check(op) PyObject_TypeCheck(op, &PyGenerator_Type) ! /* exposing the method wrapper type for pickling */ PyAPI_DATA(PyTypeObject) PyMethodWrapper_Type; --- 110,115 ---- #define PyGenerator_Check(op) PyObject_TypeCheck(op, &PyGenerator_Type) ! PyAPI_DATA(PyTypeObject) PyMethodDescr_Type; ! PyAPI_DATA(PyTypeObject) PyClassMethodDescr_Type; PyAPI_DATA(PyTypeObject) PyMethodWrapper_Type; *************** *** 161,164 **** --- 156,166 ---- (stackless ? slp_try_stackless = (flag) : 0) + #define STACKLESS_PROMOTE_METHOD(obj, meth) \ + (obj->ob_type->tp_flags & Py_TPFLAGS_HAVE_STACKLESS_EXTENSION ? \ + slp_try_stackless = stackless & obj->ob_type->slpflags.meth : 0) + + #define STACKLESS_PROMOTE_WRAPPER(wp) \ + (slp_try_stackless = stackless & wp->descr->d_slpmask) + #define STACKLESS_PROMOTE_ALL() (slp_try_stackless = stackless, NULL) *************** *** 175,178 **** --- 177,184 ---- #define STACKLESS_ASSERT() assert(!slp_try_stackless) + /* this is just a tag to denote which methods are stackless */ + + #define STACKLESS_DECLARE_METHOD(type, meth) + /* *************** *** 447,450 **** --- 453,458 ---- #define STACKLESS_PROMOTE(func) stackless = 0 #define STACKLESS_PROMOTE_FLAG(flag) stackless = 0 + #define STACKLESS_PROMOTE_METHOD(obj, meth) stackless = 0 + #define STACKLESS_PROMOTE_WRAPPER(wp) stackless = 0 #define STACKLESS_PROMOTE_ALL() stackless = 0 #define STACKLESS_PROPOSE(func) assert(1) *************** *** 454,457 **** --- 462,467 ---- #define STACKLESS_ASSERT() assert(1) + #define STACKLESS_DECLARE_METHOD(type, meth) + #endif /* STACKLESS */ Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.150 retrieving revision 1.151 diff -C2 -d -r1.150 -r1.151 *** stacklesseval.c 24 May 2004 01:45:39 -0000 1.150 --- stacklesseval.c 2 Jun 2004 23:03:43 -0000 1.151 *************** *** 356,365 **** --- 356,370 ---- PyTaskletObject *cur = ts->st.current; PyCStackObject *cst = cur->cstate; + PyCFrameObject *cf = (PyCFrameObject *) f; + ts->st.nesting_level = cf->n; ts->frame = f->f_back; Py_DECREF(f); + cur->cstate = NULL; retval = PyEval_EvalFrame(ts->frame, retval); TASKLET_SETVAL_OWN(cur, retval); /* jump back */ + Py_XDECREF(cur->cstate); + cur->cstate = cst; slp_transfer_return(cst); /* never come here */ *************** *** 386,389 **** --- 391,395 ---- if (cf == NULL) return NULL; + cf->n = ts->st.nesting_level; ts->frame = (PyFrameObject *) cf; cst = cur->cstate; _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sun Jun 6 16:05:08 2004 From: tismer at centera.de (Christian Tismer) Date: Sun, 06 Jun 2004 16:05:08 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core stacklesseval.c, 1.160, 1.161 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv28198/Stackless/core Modified Files: stacklesseval.c Log Message: removed cstack caching, no longer useful. Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.160 retrieving revision 1.161 diff -C2 -d -r1.160 -r1.161 *** a/stacklesseval.c 6 Jun 2004 13:58:14 -0000 1.160 --- b/stacklesseval.c 6 Jun 2004 14:05:05 -0000 1.161 *************** *** 43,65 **** ******************************************************/ - static PyCStackObject *cstack_cache[CSTACK_SLOTS] = { NULL }; - static int cstack_cachecount = 0; - - /* this function will get called by PyStacklessEval_Fini */ - static void slp_cstack_cacheclear(void) - { - int i; - PyCStackObject *stack; - - for (i=0; i < CSTACK_SLOTS; i++) { - while (cstack_cache[i] != NULL) { - stack = cstack_cache[i]; - cstack_cache[i] = (PyCStackObject *) stack->startaddr; - PyObject_Del(stack); - } - } - cstack_cachecount = 0; - } - static void cstack_dealloc(PyCStackObject *cst) --- 43,46 ---- *************** *** 68,81 **** SLP_CHAIN_REMOVE(PyCStackObject, &slp_cstack_chain, cst, next, prev); ! if (cst->ob_size >= CSTACK_SLOTS) { ! PyObject_Del(cst); ! } ! else { ! if (cstack_cachecount >= CSTACK_MAXCACHE) ! slp_cstack_cacheclear(); ! cst->startaddr = (int *) cstack_cache[cst->ob_size]; ! cstack_cache[cst->ob_size] = cst; ! ++cstack_cachecount; ! } } --- 49,53 ---- SLP_CHAIN_REMOVE(PyCStackObject, &slp_cstack_chain, cst, next, prev); ! PyObject_Del(cst); } *************** *** 95,106 **** Py_DECREF(*cst); } ! if (size < CSTACK_SLOTS && ((*cst) = cstack_cache[size])) { ! /* take stack from cache */ ! cstack_cache[size] = (PyCStackObject *) (*cst)->startaddr; ! --cstack_cachecount; ! _Py_NewReference((PyObject *)(*cst)); ! } ! else ! *cst = PyObject_NewVar(PyCStackObject, &PyCStack_Type, size); if (*cst == NULL) return NULL; --- 67,71 ---- Py_DECREF(*cst); } ! *cst = PyObject_NewVar(PyCStackObject, &PyCStack_Type, size); if (*cst == NULL) return NULL; *************** *** 333,337 **** PyStacklessEval_Fini(void) { ! slp_cstack_cacheclear(); } --- 298,302 ---- PyStacklessEval_Fini(void) { ! /* no caching at the moment */ } _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 14:19:17 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 14:19:17 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/module scheduling.c, 1.100, 1.101 stacklessmodule.c, 1.174, 1.175 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/module In directory centera.de:/tmp/cvs-serv6338/Stackless/module Modified Files: scheduling.c stacklessmodule.c Log Message: enhancements to the tests: they all run soft and hard. auto-scheduling now obeys schedlock. scheduler callback can raise an error, now. Index: scheduling.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/scheduling.c,v retrieving revision 1.100 retrieving revision 1.101 diff -C2 -d -r1.100 -r1.101 *** scheduling.c 2 Jun 2004 23:03:42 -0000 1.100 --- scheduling.c 3 Jun 2004 12:19:14 -0000 1.101 *************** *** 301,305 **** /* scheduler monitoring */ ! void slp_schedule_callback(PyTaskletObject *prev, PyTaskletObject *next) { --- 301,305 ---- /* scheduler monitoring */ ! int slp_schedule_callback(PyTaskletObject *prev, PyTaskletObject *next) { *************** *** 323,339 **** Py_XDECREF(ret); Py_DECREF(args); } } #define NOTIFY_SCHEDULE(prev, next, errflag) \ if (_slp_schedule_fasthook != NULL) { \ ! if (ts->st.schedlock) \ RUNTIME_ERROR( \ "Recursive scheduler call due to callbacks!", \ errflag); \ ! ts->st.schedlock = 1; \ ! _slp_schedule_fasthook(prev, next); \ ! ts->st.schedlock = 0; \ ! } static void --- 323,346 ---- Py_XDECREF(ret); Py_DECREF(args); + return ret ? 0 : -1; } + else + return -1; } #define NOTIFY_SCHEDULE(prev, next, errflag) \ if (_slp_schedule_fasthook != NULL) { \ ! int ret; \ ! if (ts->st.schedlock) { \ ! { __asm int 3} \ RUNTIME_ERROR( \ "Recursive scheduler call due to callbacks!", \ errflag); \ ! } \ ! ts->st.schedlock = 1; \ ! ret = _slp_schedule_fasthook(prev, next); \ ! ts->st.schedlock = 0; \ ! if (ret) return errflag; \ ! } static void Index: stacklessmodule.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/stacklessmodule.c,v retrieving revision 1.174 retrieving revision 1.175 diff -C2 -d -r1.174 -r1.175 *** stacklessmodule.c 2 Jun 2004 23:03:42 -0000 1.174 --- stacklessmodule.c 3 Jun 2004 12:19:14 -0000 1.175 *************** *** 189,193 **** * if nesting_level is relevant */ ! if (current->flags.atomic || ( ts->st.nesting_level && !current->flags.ignore_nesting ) ) { ts->st.ticker = ts->st.interval; --- 189,193 ---- * if nesting_level is relevant */ ! if (current->flags.atomic || ts->st.schedlock || ( ts->st.nesting_level && !current->flags.ignore_nesting ) ) { ts->st.ticker = ts->st.interval; _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sun Jun 6 17:04:43 2004 From: tismer at centera.de (Christian Tismer) Date: Sun, 06 Jun 2004 17:04:43 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/module scheduling.c, 1.106, 1.107 stacklessmodule.c, 1.175, 1.176 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/module In directory centera.de:/tmp/cvs-serv29520/Stackless/module Modified Files: scheduling.c stacklessmodule.c Log Message: re-activated cstack caching, makes very much sense, partially 30 percent more speed. Also added caches for cframes and bombs. Index: scheduling.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/scheduling.c,v retrieving revision 1.106 retrieving revision 1.107 diff -C2 -d -r1.106 -r1.107 *** a/scheduling.c 6 Jun 2004 13:58:14 -0000 1.106 --- b/scheduling.c 6 Jun 2004 15:04:41 -0000 1.107 *************** *** 14,17 **** --- 14,21 ---- ******************************************************/ + static PyBombObject *free_list = NULL; + static int numfree = 0; /* number of bombs currently in free_list */ + #define MAXFREELIST 20 /* max value for numfree */ + static void bomb_dealloc(PyBombObject *bomb) *************** *** 21,25 **** Py_XDECREF(bomb->curexc_value); Py_XDECREF(bomb->curexc_traceback); ! PyObject_GC_Del(bomb); } --- 25,35 ---- Py_XDECREF(bomb->curexc_value); Py_XDECREF(bomb->curexc_traceback); ! if (numfree < MAXFREELIST) { ! ++numfree; ! bomb->curexc_type = (PyObject *) free_list; ! free_list = bomb; ! } ! else ! PyObject_GC_Del(bomb); } *************** *** 61,67 **** PyBombObject *bomb; ! bomb = PyObject_GC_New(PyBombObject, &PyBomb_Type); ! if (bomb == NULL) ! return NULL; bomb->curexc_type = NULL; bomb->curexc_value = NULL; --- 71,86 ---- PyBombObject *bomb; ! if (free_list == NULL) { ! bomb = PyObject_GC_New(PyBombObject, &PyBomb_Type); ! if (bomb == NULL) ! return NULL; ! } ! else { ! assert(numfree > 0); ! --numfree; ! bomb = free_list; ! free_list = (PyBombObject *) free_list->curexc_type; ! _Py_NewReference((PyObject *) bomb); ! } bomb->curexc_type = NULL; bomb->curexc_value = NULL; *************** *** 1052,1054 **** --- 1071,1087 ---- } + /* Clear out the free list */ + + void + slp_scheduling_fini(void) + { + while (free_list != NULL) { + PyBombObject *bomb = free_list; + free_list = (PyBombObject *) free_list->curexc_type; + PyObject_GC_Del(bomb); + --numfree; + } + assert(numfree == 0); + } + #endif Index: stacklessmodule.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/stacklessmodule.c,v retrieving revision 1.175 retrieving revision 1.176 diff -C2 -d -r1.175 -r1.176 *** a/stacklessmodule.c 3 Jun 2004 12:19:14 -0000 1.175 --- b/stacklessmodule.c 6 Jun 2004 15:04:41 -0000 1.176 *************** *** 1030,1032 **** --- 1030,1040 ---- } + void + PyStackless_Fini(void) + { + slp_scheduling_fini(); + slp_cstack_fini(); + slp_stacklesseval_fini(); + } + #endif _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sun Jun 6 14:53:08 2004 From: tismer at centera.de (Christian Tismer) Date: Sun, 06 Jun 2004 14:53:08 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/module scheduling.c, 1.104, 1.105 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/module In directory centera.de:/tmp/cvs-serv25878/Stackless/module Modified Files: scheduling.c Log Message: temporary debug checkin Index: scheduling.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/scheduling.c,v retrieving revision 1.104 retrieving revision 1.105 diff -C2 -d -r1.104 -r1.105 *** a/scheduling.c 5 Jun 2004 20:10:38 -0000 1.104 --- b/scheduling.c 6 Jun 2004 12:53:04 -0000 1.105 *************** *** 439,443 **** check_for_deadlock(void) { ! PyThreadState *ts = PyThreadState_Get(); PyInterpreterState *interp = ts->interp; --- 439,443 ---- check_for_deadlock(void) { ! PyThreadState *ts = PyThreadState_GET(); PyInterpreterState *interp = ts->interp; *************** *** 819,825 **** --- 819,827 ---- ++ts->st.nesting_level; + printf("schedule ++ %d\n", ts->st.nesting_level); if ((ts->exc_type != NULL ? transfer_with_exc : slp_transfer)( cstprev, next->cstate, prev) == 0) { --ts->st.nesting_level; + printf("schedule -- %d\n", ts->st.nesting_level); retval = prev->tempval; Py_INCREF(retval); _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 19:34:23 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 19:34:23 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core slp_transfer.c, 1.25, 1.26 stackless_impl.h, 1.93, 1.94 stacklesseval.c, 1.154, 1.155 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv15605/Stackless/core Modified Files: slp_transfer.c stackless_impl.h stacklesseval.c Log Message: moved more things into slp_transfer.c, to prevend inlining and optimization (gcc 3.3.2 problem) Index: slp_transfer.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/slp_transfer.c,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** slp_transfer.c 3 Jun 2004 17:25:17 -0000 1.25 --- slp_transfer.c 3 Jun 2004 17:34:21 -0000 1.26 *************** *** 48,51 **** --- 48,249 ---- /* these functions must be here, too, to prevend inlining */ + /****************************************************** + + The C Stack + + ******************************************************/ + + static PyCStackObject *cstack_cache[CSTACK_SLOTS] = { NULL }; + static int cstack_cachecount = 0; + + /* this function will get called by PyStacklessEval_Fini */ + void slp_cstack_cacheclear(void) + { + int i; + PyCStackObject *stack; + + for (i=0; i < CSTACK_SLOTS; i++) { + while (cstack_cache[i] != NULL) { + stack = cstack_cache[i]; + cstack_cache[i] = (PyCStackObject *) stack->startaddr; + PyMem_Free(stack); + } + } + cstack_cachecount = 0; + } + + static void + cstack_dealloc(PyCStackObject *cst) + { + slp_cstack_chain = cst; + SLP_CHAIN_REMOVE(PyCStackObject, &slp_cstack_chain, cst, next, + prev); + if (cst->ob_size >= CSTACK_SLOTS) { + PyMem_Free(cst); + } + else { + if (cstack_cachecount >= CSTACK_MAXCACHE) + slp_cstack_cacheclear(); + cst->startaddr = (int *) cstack_cache[cst->ob_size]; + cstack_cache[cst->ob_size] = cst; + ++cstack_cachecount; + } + } + + + /* slp_cstack_save/restore moved to slp_transfer */ + + static char cstack_doc[] = + "A CStack object serves to save the stack slice which is involved\n\ + during a recursive Python call. It will also be used for pickling\n\ + of program state. This structure is highly platform dependant.\n\ + Note: For inspection, str() can dump it as a string.\ + "; + + #if SIZEOF_VOIDP == SIZEOF_INT + #define T_ADDR T_UINT + #else + #define T_ADDR T_ULONG + #endif + + + static PyMemberDef cstack_members[] = { + {"size", T_INT, offsetof(PyCStackObject, ob_size), READONLY}, + {"next", T_OBJECT, offsetof(PyCStackObject, next), READONLY}, + {"prev", T_OBJECT, offsetof(PyCStackObject, prev), READONLY}, + {"task", T_OBJECT, offsetof(PyCStackObject, task), READONLY}, + {"startaddr", T_ADDR, offsetof(PyCStackObject, startaddr), READONLY}, + {0} + }; + + /* simple string interface for inspection */ + + static PyObject * + cstack_str(PyObject *o) + { + PyCStackObject *cst = (PyCStackObject*)o; + return PyString_FromStringAndSize((char*)&cst->stack, + cst->ob_size*sizeof(cst->stack[0])); + } + + PyTypeObject PyCStack_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "stackless.cstack", + sizeof(PyCStackObject), + sizeof(PyObject *), + (destructor)cstack_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)cstack_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + cstack_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + cstack_members, /* tp_members */ + }; + + /* + * slp_eval_frame moved to slp_transfer.c + * to avoid optimization in gcc 3.3.2 + */ + + void slp_kill_tasks_with_stacks(PyThreadState *ts) + { + int count = 0; + + while (1) { + PyCStackObject *csfirst = slp_cstack_chain, *cs; + PyTaskletObject *t; + + if (csfirst == NULL) + break; + for (cs = csfirst; ; cs = cs->next) { + if (count && cs == csfirst) { + /* nothing found */ + return; + } + ++count; + if (cs->task == NULL) + continue; + if (ts != NULL && cs->tstate != ts) + continue; + break; + } + count = 0; + t = cs->task; + Py_INCREF(t); + + PyTasklet_Kill(t); + PyErr_Clear(); + + if (t->f.frame == 0) { + /* ensure a valid tstate */ + t->cstate->tstate = slp_initial_tstate; + } + Py_DECREF(t); + } + } + + PyCStackObject * + slp_cstack_new(PyCStackObject **cst, int *stackref, PyTaskletObject *task) + { + PyThreadState *ts = PyThreadState_GET(); + int *stackbase = ts->st.cstack_base; + int size = stackbase - stackref; + + if (size < 0) + RUNTIME_ERROR("negative stack size", NULL); + if (*cst && (*cst)->ob_size == size && (*cst)->ob_refcnt == 1) { + /* reuse it */ + (*cst)->task = task; + return *cst; + } + + if (*cst != NULL) { + if ((*cst)->task == task) + (*cst)->task = NULL; + Py_DECREF(*cst); + } + if (size < CSTACK_SLOTS && ((*cst) = cstack_cache[size])) { + /* take stack from cache */ + cstack_cache[size] = (PyCStackObject *) (*cst)->startaddr; + --cstack_cachecount; + } + else { + /* PyObject_NewVar is inlined */ + *cst = (PyCStackObject *) + PyObject_MALLOC(sizeof(PyCStackObject) + + (size-1) * sizeof(int*)); + if (*cst == NULL) return NULL; + } + (void) PyObject_INIT_VAR(*cst, &PyCStack_Type, size); + + (*cst)->startaddr = stackbase; + (*cst)->next = (*cst)->prev = NULL; + SLP_CHAIN_INSERT(PyCStackObject, &slp_cstack_chain, *cst, next, prev); + (*cst)->serial = ts->st.serial; + (*cst)->task = task; + (*cst)->tstate = ts; + (*cst)->nesting_level = ts->st.nesting_level; + return *cst; + } + int slp_cstack_save(PyCStackObject *cstprev) Index: stackless_impl.h =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stackless_impl.h,v retrieving revision 1.93 retrieving revision 1.94 diff -C2 -d -r1.93 -r1.94 *** stackless_impl.h 3 Jun 2004 17:18:06 -0000 1.93 --- stackless_impl.h 3 Jun 2004 17:34:21 -0000 1.94 *************** *** 43,46 **** --- 43,47 ---- PyAPI_FUNC(int) slp_cstack_save(PyCStackObject *cstprev); PyAPI_FUNC(void) slp_cstack_restore(PyCStackObject *cst); + PyAPI_FUNC(void) slp_cstack_cacheclear(void); PyAPI_FUNC(int) slp_transfer(PyCStackObject **cstprev, PyCStackObject *cst, Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.154 retrieving revision 1.155 diff -C2 -d -r1.154 -r1.155 *** stacklesseval.c 3 Jun 2004 17:25:17 -0000 1.154 --- stacklesseval.c 3 Jun 2004 17:34:21 -0000 1.155 *************** *** 37,238 **** - /****************************************************** - - The C Stack - - ******************************************************/ - - static PyCStackObject *cstack_cache[CSTACK_SLOTS] = { NULL }; - static int cstack_cachecount = 0; - - /* this function will get called by PyStacklessEval_Fini */ - static void slp_cstack_cacheclear(void) - { - int i; - PyCStackObject *stack; - - for (i=0; i < CSTACK_SLOTS; i++) { - while (cstack_cache[i] != NULL) { - stack = cstack_cache[i]; - cstack_cache[i] = (PyCStackObject *) stack->startaddr; - PyMem_Free(stack); - } - } - cstack_cachecount = 0; - } - - static void - cstack_dealloc(PyCStackObject *cst) - { - slp_cstack_chain = cst; - SLP_CHAIN_REMOVE(PyCStackObject, &slp_cstack_chain, cst, next, - prev); - if (cst->ob_size >= CSTACK_SLOTS) { - PyMem_Free(cst); - } - else { - if (cstack_cachecount >= CSTACK_MAXCACHE) - slp_cstack_cacheclear(); - cst->startaddr = (int *) cstack_cache[cst->ob_size]; - cstack_cache[cst->ob_size] = cst; - ++cstack_cachecount; - } - } - - - PyCStackObject * - slp_cstack_new(PyCStackObject **cst, int *stackref, PyTaskletObject *task) - { - PyThreadState *ts = PyThreadState_GET(); - int *stackbase = ts->st.cstack_base; - int size = stackbase - stackref; - - if (size < 0) - RUNTIME_ERROR("negative stack size", NULL); - if (*cst && (*cst)->ob_size == size && (*cst)->ob_refcnt == 1) { - /* reuse it */ - (*cst)->task = task; - return *cst; - } - - if (*cst != NULL) { - if ((*cst)->task == task) - (*cst)->task = NULL; - Py_DECREF(*cst); - } - if (size < CSTACK_SLOTS && ((*cst) = cstack_cache[size])) { - /* take stack from cache */ - cstack_cache[size] = (PyCStackObject *) (*cst)->startaddr; - --cstack_cachecount; - } - else { - /* PyObject_NewVar is inlined */ - *cst = (PyCStackObject *) - PyObject_MALLOC(sizeof(PyCStackObject) + - (size-1) * sizeof(int*)); - if (*cst == NULL) return NULL; - } - (void) PyObject_INIT_VAR(*cst, &PyCStack_Type, size); - - (*cst)->startaddr = stackbase; - (*cst)->next = (*cst)->prev = NULL; - SLP_CHAIN_INSERT(PyCStackObject, &slp_cstack_chain, *cst, next, prev); - (*cst)->serial = ts->st.serial; - (*cst)->task = task; - (*cst)->tstate = ts; - (*cst)->nesting_level = ts->st.nesting_level; - return *cst; - } - - /* slp_cstack_save/restore moved to slp_transfer */ - - static char cstack_doc[] = - "A CStack object serves to save the stack slice which is involved\n\ - during a recursive Python call. It will also be used for pickling\n\ - of program state. This structure is highly platform dependant.\n\ - Note: For inspection, str() can dump it as a string.\ - "; - - #if SIZEOF_VOIDP == SIZEOF_INT - #define T_ADDR T_UINT - #else - #define T_ADDR T_ULONG - #endif - - - static PyMemberDef cstack_members[] = { - {"size", T_INT, offsetof(PyCStackObject, ob_size), READONLY}, - {"next", T_OBJECT, offsetof(PyCStackObject, next), READONLY}, - {"prev", T_OBJECT, offsetof(PyCStackObject, prev), READONLY}, - {"task", T_OBJECT, offsetof(PyCStackObject, task), READONLY}, - {"startaddr", T_ADDR, offsetof(PyCStackObject, startaddr), READONLY}, - {0} - }; - - /* simple string interface for inspection */ - - static PyObject * - cstack_str(PyObject *o) - { - PyCStackObject *cst = (PyCStackObject*)o; - return PyString_FromStringAndSize((char*)&cst->stack, - cst->ob_size*sizeof(cst->stack[0])); - } - - PyTypeObject PyCStack_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "stackless.cstack", - sizeof(PyCStackObject), - sizeof(PyObject *), - (destructor)cstack_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)cstack_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - cstack_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - cstack_members, /* tp_members */ - }; - - /* - * slp_eval_frame moved to slp_transfer.c - * to avoid optimization in gcc 3.3.2 - */ - - void slp_kill_tasks_with_stacks(PyThreadState *ts) - { - int count = 0; - - while (1) { - PyCStackObject *csfirst = slp_cstack_chain, *cs; - PyTaskletObject *t; - - if (csfirst == NULL) - break; - for (cs = csfirst; ; cs = cs->next) { - if (count && cs == csfirst) { - /* nothing found */ - return; - } - ++count; - if (cs->task == NULL) - continue; - if (ts != NULL && cs->tstate != ts) - continue; - break; - } - count = 0; - t = cs->task; - Py_INCREF(t); - - PyTasklet_Kill(t); - PyErr_Clear(); - - if (t->f.frame == 0) { - /* ensure a valid tstate */ - t->cstate->tstate = slp_initial_tstate; - } - Py_DECREF(t); - } - } - void PyStackless_kill_tasks_with_stacks(int allthreads) { --- 37,40 ---- _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sun Jun 6 14:53:08 2004 From: tismer at centera.de (Christian Tismer) Date: Sun, 06 Jun 2004 14:53:08 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core stacklesseval.c, 1.157, 1.158 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv25878/Stackless/core Modified Files: stacklesseval.c Log Message: temporary debug checkin Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.157 retrieving revision 1.158 diff -C2 -d -r1.157 -r1.158 *** a/stacklesseval.c 4 Jun 2004 10:30:12 -0000 1.157 --- b/stacklesseval.c 6 Jun 2004 12:53:06 -0000 1.158 *************** *** 122,125 **** --- 122,126 ---- (*cst)->tstate = ts; (*cst)->nesting_level = ts->st.nesting_level; + printf("cstack new with %d\n", (*cst)->nesting_level); return *cst; } *************** *** 139,142 **** --- 140,144 ---- { cst->tstate->st.nesting_level = cst->nesting_level; + printf("cstack restore with %d\n", cst->nesting_level); /* mark task as no longer responsible for cstack instance */ cst->task = NULL; *************** *** 576,579 **** --- 578,582 ---- ++ts->st.nesting_level; + printf("dispatch ++ %d\n", ts->st.nesting_level); /* *************** *** 598,601 **** --- 601,605 ---- } --ts->st.nesting_level; + printf("dispatch -- %d\n", ts->st.nesting_level); /* see whether we need to trigger a pending interrupt */ /* note that an interrupt handler guarantees current to exist */ _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Tue Jun 29 17:53:39 2004 From: tismer at centera.de (Christian Tismer) Date: Tue, 29 Jun 2004 17:53:39 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/zlib-1.2.1 adler32.obj, 1.1.1.1, NONE compress.obj, 1.1.1.1, NONE crc32.obj, 1.1.1.1, NONE deflate.obj, 1.1.1.1, NONE example.exe, 1.1.1.1, NONE example.obj, 1.1.1.1, NONE example_d.exe, 1.1.1.1, NONE gzio.obj, 1.1.1.1, NONE infback.obj, 1.1.1.1, NONE inffast.obj, 1.1.1.1, NONE inflate.obj, 1.1.1.1, NONE inftrees.obj, 1.1.1.1, NONE minigzip.exe, 1.1.1.1, NONE minigzip.obj, 1.1.1.1, NONE minigzip_d.exe, 1.1.1.1, NONE trees.obj, 1.1.1.1, NONE uncompr.obj, 1.1.1.1, NONE zdll.lib, 1.1.1.1, NONE zlib.lib, 1.1.1.1, NONE zlib1.dll, 1.1.1.1, NONE zutil.obj, 1.1.1.1, NONE Message-ID: Update of /home/cvs/slpdev/src/2.3/zlib-1.2.1 In directory centera.de:/tmp/cvs-serv1205 Removed Files: adler32.obj compress.obj crc32.obj deflate.obj example.exe example.obj example_d.exe gzio.obj infback.obj inffast.obj inflate.obj inftrees.obj minigzip.exe minigzip.obj minigzip_d.exe trees.obj uncompr.obj zdll.lib zlib.lib zlib1.dll zutil.obj Log Message: cleanup --- adler32.obj DELETED --- --- compress.obj DELETED --- --- crc32.obj DELETED --- --- deflate.obj DELETED --- --- example.exe DELETED --- --- example.obj DELETED --- --- example_d.exe DELETED --- --- gzio.obj DELETED --- --- infback.obj DELETED --- --- inffast.obj DELETED --- --- inflate.obj DELETED --- --- inftrees.obj DELETED --- --- minigzip.exe DELETED --- --- minigzip.obj DELETED --- --- minigzip_d.exe DELETED --- --- trees.obj DELETED --- --- uncompr.obj DELETED --- --- zdll.lib DELETED --- --- zlib.lib DELETED --- --- zlib1.dll DELETED --- --- zutil.obj DELETED --- _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Fri Jun 4 12:30:17 2004 From: tismer at centera.de (Christian Tismer) Date: Fri, 04 Jun 2004 12:30:17 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core stacklesseval.c, 1.156, 1.157 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv6443/Stackless/core Modified Files: stacklesseval.c Log Message: small cleanup Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.156 retrieving revision 1.157 diff -C2 -d -r1.156 -r1.157 *** a/stacklesseval.c 3 Jun 2004 18:02:12 -0000 1.156 --- b/stacklesseval.c 4 Jun 2004 10:30:12 -0000 1.157 *************** *** 224,228 **** ts->st.serial_last_jump = ++ts->st.serial; if (slp_transfer(&ts->st.initial_stub, NULL, NULL)) return -1; - ts->st.initial_stub->serial = ts->st.serial; /* * from here, we always arrive with a compatible cstack --- 224,227 ---- _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sun Jun 6 17:04:43 2004 From: tismer at centera.de (Christian Tismer) Date: Sun, 06 Jun 2004 17:04:43 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Python pythonrun.c, 1.22, 1.23 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Python In directory centera.de:/tmp/cvs-serv29520/Python Modified Files: pythonrun.c Log Message: re-activated cstack caching, makes very much sense, partially 30 percent more speed. Also added caches for cframes and bombs. Index: pythonrun.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Python/pythonrun.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** a/pythonrun.c 2 Jun 2004 23:03:42 -0000 1.22 --- b/pythonrun.c 6 Jun 2004 15:04:41 -0000 1.23 *************** *** 437,441 **** #endif #ifdef STACKLESS ! PyStacklessEval_Fini(); #endif --- 437,441 ---- #endif #ifdef STACKLESS ! PyStackless_Fini(); #endif _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:03:46 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:03:46 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Lib/test test_hotshot.py, 1.1.1.3, 1.2 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Lib/test In directory centera.de:/tmp/cvs-serv3004/Lib/test Modified Files: test_hotshot.py Log Message: Stackless 3.1 almost ready. All tests are working, both Python and Stackless, both soft and hard switching. New features: channels are working cross-thread! Stack protection for eval_frame and pickling is complete. A couple of smallish features are missing: pickling of channels refuse running tasklets from foreign threads channel.transfer scheduling strategy cross-thread cframe pickling, get rid of invalid_exec funcs, instead use the missing cframe owner-tasklet pointer! add more tests! Index: test_hotshot.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Lib/test/test_hotshot.py,v retrieving revision 1.1.1.3 retrieving revision 1.2 diff -C2 -d -r1.1.1.3 -r1.2 *** test_hotshot.py 8 Jan 2004 22:09:42 -0000 1.1.1.3 --- test_hotshot.py 2 Jun 2004 23:03:43 -0000 1.2 *************** *** 30,33 **** --- 30,34 ---- def next(self, index=None): try: + 1 << 42##!! return hotshot.log.LogReader.next(self) except StopIteration: _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 20:02:15 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 20:02:15 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core slp_transfer.c, 1.26, 1.27 stackless_impl.h, 1.94, 1.95 stacklesseval.c, 1.155, 1.156 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv17074/Stackless/core Modified Files: slp_transfer.c stackless_impl.h stacklesseval.c Log Message: hmm, all undone. Seems to need just -O0 Index: slp_transfer.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/slp_transfer.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** slp_transfer.c 3 Jun 2004 17:34:21 -0000 1.26 --- slp_transfer.c 3 Jun 2004 18:02:11 -0000 1.27 *************** *** 46,352 **** #include "platf/slp_platformselect.h" - /* these functions must be here, too, to prevend inlining */ - - /****************************************************** - - The C Stack - - ******************************************************/ - - static PyCStackObject *cstack_cache[CSTACK_SLOTS] = { NULL }; - static int cstack_cachecount = 0; - - /* this function will get called by PyStacklessEval_Fini */ - void slp_cstack_cacheclear(void) - { - int i; - PyCStackObject *stack; - - for (i=0; i < CSTACK_SLOTS; i++) { - while (cstack_cache[i] != NULL) { - stack = cstack_cache[i]; - cstack_cache[i] = (PyCStackObject *) stack->startaddr; - PyMem_Free(stack); - } - } - cstack_cachecount = 0; - } - - static void - cstack_dealloc(PyCStackObject *cst) - { - slp_cstack_chain = cst; - SLP_CHAIN_REMOVE(PyCStackObject, &slp_cstack_chain, cst, next, - prev); - if (cst->ob_size >= CSTACK_SLOTS) { - PyMem_Free(cst); - } - else { - if (cstack_cachecount >= CSTACK_MAXCACHE) - slp_cstack_cacheclear(); - cst->startaddr = (int *) cstack_cache[cst->ob_size]; - cstack_cache[cst->ob_size] = cst; - ++cstack_cachecount; - } - } - - - /* slp_cstack_save/restore moved to slp_transfer */ - - static char cstack_doc[] = - "A CStack object serves to save the stack slice which is involved\n\ - during a recursive Python call. It will also be used for pickling\n\ - of program state. This structure is highly platform dependant.\n\ - Note: For inspection, str() can dump it as a string.\ - "; - - #if SIZEOF_VOIDP == SIZEOF_INT - #define T_ADDR T_UINT - #else - #define T_ADDR T_ULONG - #endif - - - static PyMemberDef cstack_members[] = { - {"size", T_INT, offsetof(PyCStackObject, ob_size), READONLY}, - {"next", T_OBJECT, offsetof(PyCStackObject, next), READONLY}, - {"prev", T_OBJECT, offsetof(PyCStackObject, prev), READONLY}, - {"task", T_OBJECT, offsetof(PyCStackObject, task), READONLY}, - {"startaddr", T_ADDR, offsetof(PyCStackObject, startaddr), READONLY}, - {0} - }; - - /* simple string interface for inspection */ - - static PyObject * - cstack_str(PyObject *o) - { - PyCStackObject *cst = (PyCStackObject*)o; - return PyString_FromStringAndSize((char*)&cst->stack, - cst->ob_size*sizeof(cst->stack[0])); - } - - PyTypeObject PyCStack_Type = { - PyObject_HEAD_INIT(&PyType_Type) - 0, - "stackless.cstack", - sizeof(PyCStackObject), - sizeof(PyObject *), - (destructor)cstack_dealloc, /* tp_dealloc */ - 0, /* tp_print */ - 0, /* tp_getattr */ - 0, /* tp_setattr */ - 0, /* tp_compare */ - 0, /* tp_repr */ - 0, /* tp_as_number */ - 0, /* tp_as_sequence */ - 0, /* tp_as_mapping */ - 0, /* tp_hash */ - 0, /* tp_call */ - (reprfunc)cstack_str, /* tp_str */ - PyObject_GenericGetAttr, /* tp_getattro */ - PyObject_GenericSetAttr, /* tp_setattro */ - 0, /* tp_as_buffer */ - Py_TPFLAGS_DEFAULT, /* tp_flags */ - cstack_doc, /* tp_doc */ - 0, /* tp_traverse */ - 0, /* tp_clear */ - 0, /* tp_richcompare */ - 0, /* tp_weaklistoffset */ - 0, /* tp_iter */ - 0, /* tp_iternext */ - 0, /* tp_methods */ - cstack_members, /* tp_members */ - }; - - /* - * slp_eval_frame moved to slp_transfer.c - * to avoid optimization in gcc 3.3.2 - */ - - void slp_kill_tasks_with_stacks(PyThreadState *ts) - { - int count = 0; - - while (1) { - PyCStackObject *csfirst = slp_cstack_chain, *cs; - PyTaskletObject *t; - - if (csfirst == NULL) - break; - for (cs = csfirst; ; cs = cs->next) { - if (count && cs == csfirst) { - /* nothing found */ - return; - } - ++count; - if (cs->task == NULL) - continue; - if (ts != NULL && cs->tstate != ts) - continue; - break; - } - count = 0; - t = cs->task; - Py_INCREF(t); - - PyTasklet_Kill(t); - PyErr_Clear(); - - if (t->f.frame == 0) { - /* ensure a valid tstate */ - t->cstate->tstate = slp_initial_tstate; - } - Py_DECREF(t); - } - } - - PyCStackObject * - slp_cstack_new(PyCStackObject **cst, int *stackref, PyTaskletObject *task) - { - PyThreadState *ts = PyThreadState_GET(); - int *stackbase = ts->st.cstack_base; - int size = stackbase - stackref; - - if (size < 0) - RUNTIME_ERROR("negative stack size", NULL); - if (*cst && (*cst)->ob_size == size && (*cst)->ob_refcnt == 1) { - /* reuse it */ - (*cst)->task = task; - return *cst; - } - - if (*cst != NULL) { - if ((*cst)->task == task) - (*cst)->task = NULL; - Py_DECREF(*cst); - } - if (size < CSTACK_SLOTS && ((*cst) = cstack_cache[size])) { - /* take stack from cache */ - cstack_cache[size] = (PyCStackObject *) (*cst)->startaddr; - --cstack_cachecount; - } - else { - /* PyObject_NewVar is inlined */ - *cst = (PyCStackObject *) - PyObject_MALLOC(sizeof(PyCStackObject) + - (size-1) * sizeof(int*)); - if (*cst == NULL) return NULL; - } - (void) PyObject_INIT_VAR(*cst, &PyCStack_Type, size); - - (*cst)->startaddr = stackbase; - (*cst)->next = (*cst)->prev = NULL; - SLP_CHAIN_INSERT(PyCStackObject, &slp_cstack_chain, *cst, next, prev); - (*cst)->serial = ts->st.serial; - (*cst)->task = task; - (*cst)->tstate = ts; - (*cst)->nesting_level = ts->st.nesting_level; - return *cst; - } - - int - slp_cstack_save(PyCStackObject *cstprev) - { - int stsizeb = (cstprev)->ob_size * sizeof(int*); - - memcpy((cstprev)->stack, (cstprev)->startaddr - - (cstprev)->ob_size, stsizeb); - return stsizeb; - } - - void - slp_cstack_restore(PyCStackObject *cst) - { - cst->tstate->st.nesting_level = cst->nesting_level; - /* mark task as no longer responsible for cstack instance */ - cst->task = NULL; - memcpy(cst->startaddr - cst->ob_size, &cst->stack, - (cst->ob_size) * sizeof(int*)); - } - - static int - make_initial_stub(void) - { - PyThreadState *ts = PyThreadState_GET(); - - if (ts->st.initial_stub != NULL) { - Py_DECREF(ts->st.initial_stub); - ts->st.initial_stub = NULL; - } - ts->st.serial_last_jump = ++ts->st.serial; - if (slp_transfer(&ts->st.initial_stub, NULL, NULL)) return -1; - ts->st.initial_stub->serial = ts->st.serial; - /* - * from here, we always arrive with a compatible cstack - * that also can be used by main, if it is running - * in soft-switching mode. - * To insure that, it was necessary to re-create the - * initial stub for *every* run of a new main. - * This will vanish with greenlet-like stack management. - */ - - return 0; - } - - static PyObject * - climb_stack_and_eval_frame(PyFrameObject *f) - { - /* - * a similar case to climb_stack_and_transfer, - * but here we need to incorporate a gap in the - * stack into main and keep this gap on the stack. - * This way, initial_stub is always valid to be - * used to return to the main c stack. - */ - PyThreadState *ts = PyThreadState_GET(); - int probe; - int needed = &probe - ts->st.cstack_base; - /* in rare cases, the need might have vanished due to the recursion */ - int * goobledigoobs; - - if (needed > 0) { - goobledigoobs = alloca(needed * sizeof(int)); - if (goobledigoobs == NULL) - return NULL; - } - return slp_eval_frame(f); - } - - PyObject * - slp_eval_frame(PyFrameObject *f) - { - PyThreadState *ts = PyThreadState_GET(); - PyFrameObject *fprev = f->f_back; - int * stackref; - - if (fprev == NULL && ts->st.main == NULL) { - /* this is the initial frame, so mark the stack base */ - - /* - * careful, this caused me a major headache. - * it is *not* sufficient to just check for fprev == NULL. - * Reason: (observed with wxPython): - * A toplevel frame is run as a tasklet. When its frame - * is deallocated (in tasklet_end), a Python object - * with a __del__ method is destroyed. This __del__ - * will run as a toplevel frame, with f_back == NULL! - */ - - stackref = STACK_REFPLUS + (int*) &f; - if (ts->st.cstack_base == NULL) - ts->st.cstack_base = stackref-CSTACK_GOODGAP; - if (stackref > ts->st.cstack_base) - return climb_stack_and_eval_frame(f); - - ts->frame = f; - if (make_initial_stub()) - return NULL; - return slp_run_tasklet(); - } - Py_INCREF(Py_None); - return slp_frame_dispatch(f, fprev, Py_None); - } - static int climb_stack_and_transfer(PyCStackObject **cstprev, PyCStackObject *cst, --- 46,49 ---- Index: stackless_impl.h =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stackless_impl.h,v retrieving revision 1.94 retrieving revision 1.95 diff -C2 -d -r1.94 -r1.95 *** stackless_impl.h 3 Jun 2004 17:34:21 -0000 1.94 --- stackless_impl.h 3 Jun 2004 18:02:11 -0000 1.95 *************** *** 43,47 **** PyAPI_FUNC(int) slp_cstack_save(PyCStackObject *cstprev); PyAPI_FUNC(void) slp_cstack_restore(PyCStackObject *cst); - PyAPI_FUNC(void) slp_cstack_cacheclear(void); PyAPI_FUNC(int) slp_transfer(PyCStackObject **cstprev, PyCStackObject *cst, --- 43,46 ---- Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.155 retrieving revision 1.156 diff -C2 -d -r1.155 -r1.156 *** stacklesseval.c 3 Jun 2004 17:34:21 -0000 1.155 --- stacklesseval.c 3 Jun 2004 18:02:12 -0000 1.156 *************** *** 37,40 **** --- 37,337 ---- + /****************************************************** + + The C Stack + + ******************************************************/ + + static PyCStackObject *cstack_cache[CSTACK_SLOTS] = { NULL }; + static int cstack_cachecount = 0; + + /* this function will get called by PyStacklessEval_Fini */ + static void slp_cstack_cacheclear(void) + { + int i; + PyCStackObject *stack; + + for (i=0; i < CSTACK_SLOTS; i++) { + while (cstack_cache[i] != NULL) { + stack = cstack_cache[i]; + cstack_cache[i] = (PyCStackObject *) stack->startaddr; + PyMem_Free(stack); + } + } + cstack_cachecount = 0; + } + + static void + cstack_dealloc(PyCStackObject *cst) + { + slp_cstack_chain = cst; + SLP_CHAIN_REMOVE(PyCStackObject, &slp_cstack_chain, cst, next, + prev); + if (cst->ob_size >= CSTACK_SLOTS) { + PyMem_Free(cst); + } + else { + if (cstack_cachecount >= CSTACK_MAXCACHE) + slp_cstack_cacheclear(); + cst->startaddr = (int *) cstack_cache[cst->ob_size]; + cstack_cache[cst->ob_size] = cst; + ++cstack_cachecount; + } + } + + + PyCStackObject * + slp_cstack_new(PyCStackObject **cst, int *stackref, PyTaskletObject *task) + { + PyThreadState *ts = PyThreadState_GET(); + int *stackbase = ts->st.cstack_base; + int size = stackbase - stackref; + + if (size < 0) + RUNTIME_ERROR("negative stack size", NULL); + if (*cst && (*cst)->ob_size == size && (*cst)->ob_refcnt == 1) { + /* reuse it */ + (*cst)->task = task; + return *cst; + } + + if (*cst != NULL) { + if ((*cst)->task == task) + (*cst)->task = NULL; + Py_DECREF(*cst); + } + if (size < CSTACK_SLOTS && ((*cst) = cstack_cache[size])) { + /* take stack from cache */ + cstack_cache[size] = (PyCStackObject *) (*cst)->startaddr; + --cstack_cachecount; + } + else { + /* PyObject_NewVar is inlined */ + *cst = (PyCStackObject *) + PyObject_MALLOC(sizeof(PyCStackObject) + + (size-1) * sizeof(int*)); + if (*cst == NULL) return NULL; + } + (void) PyObject_INIT_VAR(*cst, &PyCStack_Type, size); + + (*cst)->startaddr = stackbase; + (*cst)->next = (*cst)->prev = NULL; + SLP_CHAIN_INSERT(PyCStackObject, &slp_cstack_chain, *cst, next, prev); + (*cst)->serial = ts->st.serial; + (*cst)->task = task; + (*cst)->tstate = ts; + (*cst)->nesting_level = ts->st.nesting_level; + return *cst; + } + + int + slp_cstack_save(PyCStackObject *cstprev) + { + int stsizeb = (cstprev)->ob_size * sizeof(int*); + + memcpy((cstprev)->stack, (cstprev)->startaddr - + (cstprev)->ob_size, stsizeb); + return stsizeb; + } + + void + slp_cstack_restore(PyCStackObject *cst) + { + cst->tstate->st.nesting_level = cst->nesting_level; + /* mark task as no longer responsible for cstack instance */ + cst->task = NULL; + memcpy(cst->startaddr - cst->ob_size, &cst->stack, + (cst->ob_size) * sizeof(int*)); + } + + + static char cstack_doc[] = + "A CStack object serves to save the stack slice which is involved\n\ + during a recursive Python call. It will also be used for pickling\n\ + of program state. This structure is highly platform dependant.\n\ + Note: For inspection, str() can dump it as a string.\ + "; + + #if SIZEOF_VOIDP == SIZEOF_INT + #define T_ADDR T_UINT + #else + #define T_ADDR T_ULONG + #endif + + + static PyMemberDef cstack_members[] = { + {"size", T_INT, offsetof(PyCStackObject, ob_size), READONLY}, + {"next", T_OBJECT, offsetof(PyCStackObject, next), READONLY}, + {"prev", T_OBJECT, offsetof(PyCStackObject, prev), READONLY}, + {"task", T_OBJECT, offsetof(PyCStackObject, task), READONLY}, + {"startaddr", T_ADDR, offsetof(PyCStackObject, startaddr), READONLY}, + {0} + }; + + /* simple string interface for inspection */ + + static PyObject * + cstack_str(PyObject *o) + { + PyCStackObject *cst = (PyCStackObject*)o; + return PyString_FromStringAndSize((char*)&cst->stack, + cst->ob_size*sizeof(cst->stack[0])); + } + + PyTypeObject PyCStack_Type = { + PyObject_HEAD_INIT(&PyType_Type) + 0, + "stackless.cstack", + sizeof(PyCStackObject), + sizeof(PyObject *), + (destructor)cstack_dealloc, /* tp_dealloc */ + 0, /* tp_print */ + 0, /* tp_getattr */ + 0, /* tp_setattr */ + 0, /* tp_compare */ + 0, /* tp_repr */ + 0, /* tp_as_number */ + 0, /* tp_as_sequence */ + 0, /* tp_as_mapping */ + 0, /* tp_hash */ + 0, /* tp_call */ + (reprfunc)cstack_str, /* tp_str */ + PyObject_GenericGetAttr, /* tp_getattro */ + PyObject_GenericSetAttr, /* tp_setattro */ + 0, /* tp_as_buffer */ + Py_TPFLAGS_DEFAULT, /* tp_flags */ + cstack_doc, /* tp_doc */ + 0, /* tp_traverse */ + 0, /* tp_clear */ + 0, /* tp_richcompare */ + 0, /* tp_weaklistoffset */ + 0, /* tp_iter */ + 0, /* tp_iternext */ + 0, /* tp_methods */ + cstack_members, /* tp_members */ + }; + + + static int + make_initial_stub(void) + { + PyThreadState *ts = PyThreadState_GET(); + + if (ts->st.initial_stub != NULL) { + Py_DECREF(ts->st.initial_stub); + ts->st.initial_stub = NULL; + } + ts->st.serial_last_jump = ++ts->st.serial; + if (slp_transfer(&ts->st.initial_stub, NULL, NULL)) return -1; + ts->st.initial_stub->serial = ts->st.serial; + /* + * from here, we always arrive with a compatible cstack + * that also can be used by main, if it is running + * in soft-switching mode. + * To insure that, it was necessary to re-create the + * initial stub for *every* run of a new main. + * This will vanish with greenlet-like stack management. + */ + + return 0; + } + + static PyObject * + climb_stack_and_eval_frame(PyFrameObject *f) + { + /* + * a similar case to climb_stack_and_transfer, + * but here we need to incorporate a gap in the + * stack into main and keep this gap on the stack. + * This way, initial_stub is always valid to be + * used to return to the main c stack. + */ + PyThreadState *ts = PyThreadState_GET(); + int probe; + int needed = &probe - ts->st.cstack_base; + /* in rare cases, the need might have vanished due to the recursion */ + int * goobledigoobs; + + if (needed > 0) { + goobledigoobs = alloca(needed * sizeof(int)); + if (goobledigoobs == NULL) + return NULL; + } + return slp_eval_frame(f); + } + + + PyObject * + slp_eval_frame(PyFrameObject *f) + { + PyThreadState *ts = PyThreadState_GET(); + PyFrameObject *fprev = f->f_back; + int * stackref; + + if (fprev == NULL && ts->st.main == NULL) { + /* this is the initial frame, so mark the stack base */ + + /* + * careful, this caused me a major headache. + * it is *not* sufficient to just check for fprev == NULL. + * Reason: (observed with wxPython): + * A toplevel frame is run as a tasklet. When its frame + * is deallocated (in tasklet_end), a Python object + * with a __del__ method is destroyed. This __del__ + * will run as a toplevel frame, with f_back == NULL! + */ + + stackref = STACK_REFPLUS + (int*) &f; + if (ts->st.cstack_base == NULL) + ts->st.cstack_base = stackref-CSTACK_GOODGAP; + if (stackref > ts->st.cstack_base) + return climb_stack_and_eval_frame(f); + + ts->frame = f; + if (make_initial_stub()) + return NULL; + return slp_run_tasklet(); + } + Py_INCREF(Py_None); + return slp_frame_dispatch(f, fprev, Py_None); + } + + void slp_kill_tasks_with_stacks(PyThreadState *ts) + { + int count = 0; + + while (1) { + PyCStackObject *csfirst = slp_cstack_chain, *cs; + PyTaskletObject *t; + + if (csfirst == NULL) + break; + for (cs = csfirst; ; cs = cs->next) { + if (count && cs == csfirst) { + /* nothing found */ + return; + } + ++count; + if (cs->task == NULL) + continue; + if (ts != NULL && cs->tstate != ts) + continue; + break; + } + count = 0; + t = cs->task; + Py_INCREF(t); + + PyTasklet_Kill(t); + PyErr_Clear(); + + if (t->f.frame == 0) { + /* ensure a valid tstate */ + t->cstate->tstate = slp_initial_tstate; + } + Py_DECREF(t); + } + } + void PyStackless_kill_tasks_with_stacks(int allthreads) { _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Tue Jun 29 17:44:36 2004 From: tismer at centera.de (Christian Tismer) Date: Tue, 29 Jun 2004 17:44:36 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/zlib-1.2.1 - Imported sources Message-ID: Update of /home/cvs/slpdev/src/2.3/zlib-1.2.1 In directory centera.de:/tmp/cvs-serv963 Log Message: added zlib to library Status: Vendor Tag: avendor Release Tags: arelease N slpdev/src/2.3/zlib-1.2.1/adler32.c N slpdev/src/2.3/zlib-1.2.1/adler32.obj N slpdev/src/2.3/zlib-1.2.1/algorithm.txt N slpdev/src/2.3/zlib-1.2.1/ChangeLog N slpdev/src/2.3/zlib-1.2.1/compress.c N slpdev/src/2.3/zlib-1.2.1/compress.obj N slpdev/src/2.3/zlib-1.2.1/configure N slpdev/src/2.3/zlib-1.2.1/crc32.c N slpdev/src/2.3/zlib-1.2.1/crc32.h N slpdev/src/2.3/zlib-1.2.1/crc32.obj N slpdev/src/2.3/zlib-1.2.1/deflate.c N slpdev/src/2.3/zlib-1.2.1/deflate.h N slpdev/src/2.3/zlib-1.2.1/deflate.obj N slpdev/src/2.3/zlib-1.2.1/example.c N slpdev/src/2.3/zlib-1.2.1/example.exe N slpdev/src/2.3/zlib-1.2.1/example.obj N slpdev/src/2.3/zlib-1.2.1/example_d.exe N slpdev/src/2.3/zlib-1.2.1/FAQ N slpdev/src/2.3/zlib-1.2.1/gzio.c N slpdev/src/2.3/zlib-1.2.1/gzio.obj N slpdev/src/2.3/zlib-1.2.1/INDEX N slpdev/src/2.3/zlib-1.2.1/infback.c N slpdev/src/2.3/zlib-1.2.1/infback.obj N slpdev/src/2.3/zlib-1.2.1/inffast.c N slpdev/src/2.3/zlib-1.2.1/inffast.h N slpdev/src/2.3/zlib-1.2.1/inffast.obj N slpdev/src/2.3/zlib-1.2.1/inffixed.h N slpdev/src/2.3/zlib-1.2.1/inflate.c N slpdev/src/2.3/zlib-1.2.1/inflate.h N slpdev/src/2.3/zlib-1.2.1/inflate.obj N slpdev/src/2.3/zlib-1.2.1/inftrees.c N slpdev/src/2.3/zlib-1.2.1/inftrees.h N slpdev/src/2.3/zlib-1.2.1/inftrees.obj N slpdev/src/2.3/zlib-1.2.1/Makefile N slpdev/src/2.3/zlib-1.2.1/Makefile.in N slpdev/src/2.3/zlib-1.2.1/minigzip.c N slpdev/src/2.3/zlib-1.2.1/minigzip.exe N slpdev/src/2.3/zlib-1.2.1/minigzip.obj N slpdev/src/2.3/zlib-1.2.1/minigzip_d.exe N slpdev/src/2.3/zlib-1.2.1/README N slpdev/src/2.3/zlib-1.2.1/trees.c N slpdev/src/2.3/zlib-1.2.1/trees.h N slpdev/src/2.3/zlib-1.2.1/trees.obj N slpdev/src/2.3/zlib-1.2.1/uncompr.c N slpdev/src/2.3/zlib-1.2.1/uncompr.obj N slpdev/src/2.3/zlib-1.2.1/zconf.h N slpdev/src/2.3/zlib-1.2.1/zconf.in.h N slpdev/src/2.3/zlib-1.2.1/zdll.exp N slpdev/src/2.3/zlib-1.2.1/zdll.lib N slpdev/src/2.3/zlib-1.2.1/zlib.3 N slpdev/src/2.3/zlib-1.2.1/zlib.h N slpdev/src/2.3/zlib-1.2.1/zlib.lib N slpdev/src/2.3/zlib-1.2.1/zlib1.dll N slpdev/src/2.3/zlib-1.2.1/zlib1.res N slpdev/src/2.3/zlib-1.2.1/zutil.c N slpdev/src/2.3/zlib-1.2.1/zutil.h N slpdev/src/2.3/zlib-1.2.1/zutil.obj N slpdev/src/2.3/zlib-1.2.1/amiga/Makefile.pup N slpdev/src/2.3/zlib-1.2.1/amiga/Makefile.sas N slpdev/src/2.3/zlib-1.2.1/as400/bndsrc N slpdev/src/2.3/zlib-1.2.1/as400/compile.clp N slpdev/src/2.3/zlib-1.2.1/as400/readme.txt N slpdev/src/2.3/zlib-1.2.1/as400/zlib.inc N slpdev/src/2.3/zlib-1.2.1/contrib/README.contrib N slpdev/src/2.3/zlib-1.2.1/contrib/visual-basic.txt N slpdev/src/2.3/zlib-1.2.1/contrib/ada/mtest.adb N slpdev/src/2.3/zlib-1.2.1/contrib/ada/read.adb N slpdev/src/2.3/zlib-1.2.1/contrib/ada/readme.txt N slpdev/src/2.3/zlib-1.2.1/contrib/ada/test.adb N slpdev/src/2.3/zlib-1.2.1/contrib/ada/zlib-streams.adb N slpdev/src/2.3/zlib-1.2.1/contrib/ada/zlib-streams.ads N slpdev/src/2.3/zlib-1.2.1/contrib/ada/zlib-thin.adb N slpdev/src/2.3/zlib-1.2.1/contrib/ada/zlib-thin.ads N slpdev/src/2.3/zlib-1.2.1/contrib/ada/zlib.adb N slpdev/src/2.3/zlib-1.2.1/contrib/ada/zlib.ads N slpdev/src/2.3/zlib-1.2.1/contrib/ada/zlib.gpr N slpdev/src/2.3/zlib-1.2.1/contrib/asm586/match.S N slpdev/src/2.3/zlib-1.2.1/contrib/asm586/README.586 N slpdev/src/2.3/zlib-1.2.1/contrib/asm686/match.S N slpdev/src/2.3/zlib-1.2.1/contrib/asm686/README.686 N slpdev/src/2.3/zlib-1.2.1/contrib/blast/blast.c N slpdev/src/2.3/zlib-1.2.1/contrib/blast/blast.h N slpdev/src/2.3/zlib-1.2.1/contrib/blast/Makefile N slpdev/src/2.3/zlib-1.2.1/contrib/blast/README N slpdev/src/2.3/zlib-1.2.1/contrib/blast/test.pk N slpdev/src/2.3/zlib-1.2.1/contrib/blast/test.txt N slpdev/src/2.3/zlib-1.2.1/contrib/delphi/readme.txt N slpdev/src/2.3/zlib-1.2.1/contrib/delphi/ZLib.pas N slpdev/src/2.3/zlib-1.2.1/contrib/delphi/ZLibConst.pas N slpdev/src/2.3/zlib-1.2.1/contrib/delphi/zlibd32.mak N slpdev/src/2.3/zlib-1.2.1/contrib/gzappend/gzappend.c N slpdev/src/2.3/zlib-1.2.1/contrib/infback9/infback9.c N slpdev/src/2.3/zlib-1.2.1/contrib/infback9/infback9.h N slpdev/src/2.3/zlib-1.2.1/contrib/infback9/inffix9.h N slpdev/src/2.3/zlib-1.2.1/contrib/infback9/inflate9.h N slpdev/src/2.3/zlib-1.2.1/contrib/infback9/inftree9.c N slpdev/src/2.3/zlib-1.2.1/contrib/infback9/inftree9.h N slpdev/src/2.3/zlib-1.2.1/contrib/infback9/README N slpdev/src/2.3/zlib-1.2.1/contrib/inflate86/inffas86.c N slpdev/src/2.3/zlib-1.2.1/contrib/inflate86/inffast.S N slpdev/src/2.3/zlib-1.2.1/contrib/iostream/test.cpp N slpdev/src/2.3/zlib-1.2.1/contrib/iostream/zfstream.cpp N slpdev/src/2.3/zlib-1.2.1/contrib/iostream/zfstream.h N slpdev/src/2.3/zlib-1.2.1/contrib/iostream2/zstream.h N slpdev/src/2.3/zlib-1.2.1/contrib/iostream2/zstream_test.cpp N slpdev/src/2.3/zlib-1.2.1/contrib/iostream3/README N slpdev/src/2.3/zlib-1.2.1/contrib/iostream3/test.cc N slpdev/src/2.3/zlib-1.2.1/contrib/iostream3/TODO N slpdev/src/2.3/zlib-1.2.1/contrib/iostream3/zfstream.cc N slpdev/src/2.3/zlib-1.2.1/contrib/iostream3/zfstream.h N slpdev/src/2.3/zlib-1.2.1/contrib/masm686/match.asm N slpdev/src/2.3/zlib-1.2.1/contrib/masmx86/gvmat32.asm N slpdev/src/2.3/zlib-1.2.1/contrib/masmx86/gvmat32c.c N slpdev/src/2.3/zlib-1.2.1/contrib/masmx86/inffas32.asm N slpdev/src/2.3/zlib-1.2.1/contrib/masmx86/mkasm.bat N slpdev/src/2.3/zlib-1.2.1/contrib/masmx86/readme.txt N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/ChangeLogUnzip N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/crypt.h N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/ioapi.c N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/ioapi.h N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/iowin32.c N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/iowin32.h N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/Makefile N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/miniunz.c N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/minizip.c N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/unzip.c N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/unzip.h N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/zip.c N slpdev/src/2.3/zlib-1.2.1/contrib/minizip/zip.h N slpdev/src/2.3/zlib-1.2.1/contrib/pascal/example.pas N slpdev/src/2.3/zlib-1.2.1/contrib/pascal/readme.txt N slpdev/src/2.3/zlib-1.2.1/contrib/pascal/zlibd32.mak N slpdev/src/2.3/zlib-1.2.1/contrib/pascal/zlibpas.pas N slpdev/src/2.3/zlib-1.2.1/contrib/puff/Makefile N slpdev/src/2.3/zlib-1.2.1/contrib/puff/puff.c N slpdev/src/2.3/zlib-1.2.1/contrib/puff/puff.h N slpdev/src/2.3/zlib-1.2.1/contrib/puff/README N slpdev/src/2.3/zlib-1.2.1/contrib/puff/zeros.raw N slpdev/src/2.3/zlib-1.2.1/contrib/testzlib/testzlib.c N slpdev/src/2.3/zlib-1.2.1/contrib/testzlib/testzlib.sln N slpdev/src/2.3/zlib-1.2.1/contrib/testzlib/testzlib.vcproj N slpdev/src/2.3/zlib-1.2.1/contrib/untgz/Makefile N slpdev/src/2.3/zlib-1.2.1/contrib/untgz/Makefile.msc N slpdev/src/2.3/zlib-1.2.1/contrib/untgz/untgz.c N slpdev/src/2.3/zlib-1.2.1/contrib/vstudio/readme.txt N slpdev/src/2.3/zlib-1.2.1/contrib/vstudio/vc7/gvmat32.obj N slpdev/src/2.3/zlib-1.2.1/contrib/vstudio/vc7/inffas32.obj N slpdev/src/2.3/zlib-1.2.1/contrib/vstudio/vc7/miniunz.vcproj N slpdev/src/2.3/zlib-1.2.1/contrib/vstudio/vc7/minizip.vcproj N slpdev/src/2.3/zlib-1.2.1/contrib/vstudio/vc7/zlib.rc N slpdev/src/2.3/zlib-1.2.1/contrib/vstudio/vc7/zlibstat.vcproj N slpdev/src/2.3/zlib-1.2.1/contrib/vstudio/vc7/zlibvc.def N slpdev/src/2.3/zlib-1.2.1/contrib/vstudio/vc7/zlibvc.sln N slpdev/src/2.3/zlib-1.2.1/contrib/vstudio/vc7/zlibvc.vcproj N slpdev/src/2.3/zlib-1.2.1/msdos/Makefile.bor N slpdev/src/2.3/zlib-1.2.1/msdos/Makefile.dj2 N slpdev/src/2.3/zlib-1.2.1/msdos/Makefile.emx N slpdev/src/2.3/zlib-1.2.1/msdos/Makefile.msc N slpdev/src/2.3/zlib-1.2.1/msdos/Makefile.tc N slpdev/src/2.3/zlib-1.2.1/old/descrip.mms N slpdev/src/2.3/zlib-1.2.1/old/Makefile.riscos N slpdev/src/2.3/zlib-1.2.1/old/Make_vms.com N slpdev/src/2.3/zlib-1.2.1/old/README N slpdev/src/2.3/zlib-1.2.1/old/zlib.html N slpdev/src/2.3/zlib-1.2.1/old/os2/Makefile.os2 N slpdev/src/2.3/zlib-1.2.1/old/os2/zlib.def N slpdev/src/2.3/zlib-1.2.1/qnx/package.qpg N slpdev/src/2.3/zlib-1.2.1/win32/DLL_FAQ.txt N slpdev/src/2.3/zlib-1.2.1/win32/Makefile.bor N slpdev/src/2.3/zlib-1.2.1/win32/Makefile.emx N slpdev/src/2.3/zlib-1.2.1/win32/Makefile.gcc N slpdev/src/2.3/zlib-1.2.1/win32/Makefile.msc N slpdev/src/2.3/zlib-1.2.1/win32/zlib.def N slpdev/src/2.3/zlib-1.2.1/win32/zlib1.rc No conflicts created by this import ***** Bogus filespec: - Imported sources _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:14:55 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:14:55 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core extract_slp_info.py, NONE, 1.1 extract_slp_methods.py, NONE, 1.1 slp_exttype.h, NONE, 1.1 stackless_methods.h, NONE, 1.1 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv11147 Added Files: extract_slp_info.py extract_slp_methods.py slp_exttype.h stackless_methods.h Log Message: new files added --- NEW FILE: extract_slp_info.py --- ################################################################ # # extract_slp_info.py # # extract slotnames from typeonject.c and create a structure # for inclusion into PyHeaptypeObject. # ################################################################ srcname = "../../Objects/typeobject.c" dstname = "slp_exttype.h" def parse(): f = file(srcname) line = "" slots = [] buf = "" for line in f: if line.endswith("\\\n"): buf += line else: feed(buf+line, slots) buf = "" return slots def feed(line, slots): pieces = line.split("(") if len(pieces) < 2: return first = pieces[0].strip() if len(first.split()) > 1: return if first.startswith("COPY"): print line slot = pieces[1].split(")")[0].strip() elif first.endswith("SLOT"): print line slot = pieces[1].split(",")[1].strip() else: return if slot not in slots: slots.append(slot) def generate(): slotnames = parse() f = file(dstname, "w") print >> f, """\ /* * this file was generated from typeobject.c using the script * Stackless/core/extract_slp_info.py . * please don't edit this output, but work on the script. */ typedef struct _slp_methodflags {\ """ for slot in slotnames: print >> f, "\tsigned char %s;" % slot print >> f, "} slp_methodflags;" if __name__ == "__main__": generate() --- NEW FILE: extract_slp_methods.py --- ################################################################ # # extract_slp_methods.py # # scan all C sources for the STACKLESS_DECLARE_METHOD macro # and create and include file for the module. # ################################################################ import os srcname = "../.." dstname = "stackless_methods.h" def cfiles(rootpath): work = [rootpath] while work: path = work.pop(0) for name in os.listdir(path): fname = os.path.join(path, name) if os.path.isdir(fname): work.append(fname) elif os.path.splitext(fname)[-1] == ".c": yield fname def parse(fname): find = "STACKLESS_DECLARE_METHOD" txt = file(fname).read() if txt.find(find) < 0: return lines = txt.split("\n") res = [line for line in lines if line.startswith(find)] return res def generate(): f = file(dstname, "w") print >> f, """\ /* * this file was generated from the Python C sources using the script * Stackless/core/extract_slp_methods.py . * please don't edit this output, but work on the script. */ typedef struct { PyTypeObject *type; size_t offset; } _stackless_method; #define MFLAG_OFS(meth) offsetof(PyTypeObject, slpflags.meth) static _stackless_method _stackless_methtable[] = {\ """ for fname in cfiles(srcname): found = parse(fname); if not found: continue name = os.path.split(fname)[-1] print >> f, "\t/* from %s */" % name for line in found: typ, meth = line.split("(")[-1].split(")")[0].split(", ") tabs = "\t" lng = len(typ) + 2 while lng < 24: tabs += "\t" lng += 8 print >> f, "\t{%s,%sMFLAG_OFS(%s)}," % \ (typ.strip(), tabs, meth.strip()) print >> f, "\t{0, 0} /* sentinel */" print >> f, "};" if __name__ == "__main__": generate() --- NEW FILE: slp_exttype.h --- /* * this file was generated from typeobject.c using the script * Stackless/core/extract_slp_info.py . * please don't edit this output, but work on the script. */ typedef struct _slp_methodflags { signed char tp_itemsize; signed char tp_weaklistoffset; signed char tp_dictoffset; signed char nb_add; signed char nb_subtract; signed char nb_multiply; signed char nb_divide; signed char nb_remainder; signed char nb_divmod; signed char nb_power; signed char nb_negative; signed char nb_positive; signed char nb_absolute; signed char nb_nonzero; signed char nb_invert; signed char nb_lshift; signed char nb_rshift; signed char nb_and; signed char nb_xor; signed char nb_or; signed char nb_coerce; signed char nb_int; signed char nb_long; signed char nb_float; signed char nb_oct; signed char nb_hex; signed char nb_inplace_add; signed char nb_inplace_subtract; signed char nb_inplace_multiply; signed char nb_inplace_divide; signed char nb_inplace_remainder; signed char nb_inplace_power; signed char nb_inplace_lshift; signed char nb_inplace_rshift; signed char nb_inplace_and; signed char nb_inplace_xor; signed char nb_inplace_or; signed char nb_true_divide; signed char nb_floor_divide; signed char nb_inplace_true_divide; signed char nb_inplace_floor_divide; signed char sq_length; signed char sq_concat; signed char sq_repeat; signed char sq_item; signed char sq_slice; signed char sq_ass_item; signed char sq_ass_slice; signed char sq_contains; signed char sq_inplace_concat; signed char sq_inplace_repeat; signed char mp_length; signed char mp_subscript; signed char mp_ass_subscript; signed char bf_getreadbuffer; signed char bf_getwritebuffer; signed char bf_getsegcount; signed char bf_getcharbuffer; signed char tp_dealloc; signed char tp_print; signed char tp_repr; signed char tp_call; signed char tp_str; signed char tp_compare; signed char tp_iter; signed char tp_iternext; signed char tp_descr_get; signed char tp_descr_set; signed char tp_init; signed char tp_alloc; signed char tp_is_gc; signed char tp_free; signed char tp_hash; signed char tp_getattro; signed char tp_getattr; signed char tp_setattro; signed char tp_setattr; signed char tp_richcompare; signed char tp_new; signed char tp_del; } slp_methodflags; --- NEW FILE: stackless_methods.h --- /* * this file was generated from the Python C sources using the script * Stackless/core/extract_slp_methods.py . * please don't edit this output, but work on the script. */ typedef struct { PyTypeObject *type; size_t offset; } _stackless_method; #define MFLAG_OFS(meth) offsetof(PyTypeObject, slpflags.meth) static _stackless_method _stackless_methtable[] = { /* from classobject.c */ {&PyInstance_Type, MFLAG_OFS(tp_call)}, {&PyMethod_Type, MFLAG_OFS(tp_call)}, /* from descrobject.c */ {&PyMethodDescr_Type, MFLAG_OFS(tp_call)}, {&PyClassMethodDescr_Type, MFLAG_OFS(tp_call)}, {&PyWrapperDescr_Type, MFLAG_OFS(tp_call)}, {&PyMethodWrapper_Type, MFLAG_OFS(tp_call)}, /* from funcobject.c */ {&PyFunction_Type, MFLAG_OFS(tp_call)}, /* from methodobject.c */ {&PyCFunction_Type, MFLAG_OFS(tp_call)}, /* from ceval.c */ {&PyGenerator_Type, MFLAG_OFS(tp_iternext)}, {0, 0} /* sentinel */ }; _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Tue Jun 29 17:36:29 2004 From: tismer at centera.de (Christian Tismer) Date: Tue, 29 Jun 2004 17:36:29 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/bzip2-1.0.2 - New directory Message-ID: Update of /home/cvs/slpdev/src/2.3/bzip2-1.0.2 In directory centera.de:/tmp/cvs-serv621/bzip2-1.0.2 Log Message: Directory /home/cvs/slpdev/src/2.3/bzip2-1.0.2 added to the repository _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:08:49 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:08:49 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/PCbuild mkversion.py, 1.2, 1.3 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/PCbuild In directory centera.de:/tmp/cvs-serv3588/PCbuild Modified Files: mkversion.py Log Message: this is Stackless 3.1 beta 3 Index: mkversion.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/PCbuild/mkversion.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** mkversion.py 27 Jun 2003 06:38:22 -0000 1.2 --- mkversion.py 2 Jun 2004 23:08:47 -0000 1.3 *************** *** 1,5 **** # create a new stackless version include. ! SLP_MAJOR = "3.0" import sys, os, time --- 1,5 ---- # create a new stackless version include. ! SLP_MAJOR = "3.1b3" import sys, os, time _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:03:46 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:03:46 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/unittests runAll.py, 1.3, 1.4 test_miscell.py, 1.4, 1.5 test_pickle.py, 1.10, 1.11 test_watchdog.py, 1.6, 1.7 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/unittests In directory centera.de:/tmp/cvs-serv3004/Stackless/unittests Modified Files: runAll.py test_miscell.py test_pickle.py test_watchdog.py Log Message: Stackless 3.1 almost ready. All tests are working, both Python and Stackless, both soft and hard switching. New features: channels are working cross-thread! Stack protection for eval_frame and pickling is complete. A couple of smallish features are missing: pickling of channels refuse running tasklets from foreign threads channel.transfer scheduling strategy cross-thread cframe pickling, get rid of invalid_exec funcs, instead use the missing cframe owner-tasklet pointer! add more tests! Index: runAll.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/unittests/runAll.py,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** runAll.py 18 Apr 2004 15:14:37 -0000 1.3 --- runAll.py 2 Jun 2004 23:03:43 -0000 1.4 *************** *** 7,14 **** ! import os, sys, glob, unittest ! def makeSuite(): "Build a test suite of all available test files." --- 7,18 ---- ! import os, sys, glob, unittest, stackless + def getsoft(): + hold = stackless.enable_softswitch(False) + stackless.enable_softswitch(hold) + return hold ! def makeSuite(target): "Build a test suite of all available test files." *************** *** 17,25 **** sys.path.insert(0, '.') ! for filename in glob.glob('test_*.py'): modname = os.path.splitext(os.path.basename(filename))[0] module = __import__(modname) tests = unittest.TestLoader().loadTestsFromModule(module) ! suite.addTest(tests) return suite --- 21,36 ---- sys.path.insert(0, '.') ! for idx, filename in enumerate(glob.glob('test_*.py')): modname = os.path.splitext(os.path.basename(filename))[0] + if modname in sys.modules: + del sys.modules[modname] module = __import__(modname) tests = unittest.TestLoader().loadTestsFromModule(module) ! use_it = target == 0 or idx+1 == target ! if use_it: ! suite.addTest(tests) ! if target > 0: ! print "single test of '%s', switch=%s" % \ ! (filename, ("hard", "soft")[getsoft()]) return suite *************** *** 27,30 **** if __name__ == '__main__': ! testSuite = makeSuite() ! unittest.TextTestRunner().run(testSuite) --- 38,60 ---- if __name__ == '__main__': ! hold = stackless.enable_softswitch(True) ! try: ! target = int(sys.argv[1]) ! except IndexError: ! try: ! target = TARGET ! except NameError: ! target = 0 ! try: ! flags = True, False ! if target: ! flags = (flags[target > 0],) ! if abs(target) == 42: ! target = 0 ! for switch in flags: ! stackless.enable_softswitch(switch) ! testSuite = makeSuite(abs(target)) ! unittest.TextTestRunner().run(testSuite) ! finally: ! stackless.enable_softswitch(hold) ! \ No newline at end of file Index: test_miscell.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/unittests/test_miscell.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** test_miscell.py 23 Apr 2004 00:34:38 -0000 1.4 --- test_miscell.py 2 Jun 2004 23:03:43 -0000 1.5 *************** *** 5,8 **** --- 5,11 ---- import stackless + softswitch = stackless.enable_softswitch(0) + stackless.enable_softswitch(softswitch) + def runtask(): x = 0 *************** *** 20,23 **** --- 23,28 ---- self.assert_(t.scheduled) self.assertEquals(t.recursion_depth, 0) + # allow hard switching + t.set_ignore_nesting(1) # Run a little *************** *** 46,50 **** self.lifecycle(t) - def test_aliveness2(self): """ Same as 1, but with a pickled unrun tasklet. """ --- 51,54 ---- *************** *** 56,60 **** self.lifecycle(t_new) ! def test_aliveness3(self): """ Same as 1, but with a pickled run(slightly) tasklet. """ --- 60,65 ---- self.lifecycle(t_new) ! if not softswitch: del test_aliveness2 ! def test_aliveness3(self): """ Same as 1, but with a pickled run(slightly) tasklet. """ *************** *** 99,102 **** --- 104,109 ---- self.assertEquals(t.recursion_depth, 0) + if not softswitch: del test_aliveness3 + #/////////////////////////////////////////////////////////////////////////////// Index: test_pickle.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/unittests/test_pickle.py,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** test_pickle.py 3 May 2004 16:53:39 -0000 1.10 --- test_pickle.py 2 Jun 2004 23:03:43 -0000 1.11 *************** *** 4,8 **** import cPickle as pickle ! from stackless import schedule, tasklet --- 4,8 ---- import cPickle as pickle ! from stackless import schedule, tasklet, stackless *************** *** 84,188 **** return i ! class TestPickledTasklets(unittest.TestCase): ! def setUp(self): ! self.verbose = VERBOSE ! def tearDown(self): ! del self.verbose ! def run_pickled(self, func, *args): ! ident = object() ! t = tasklet(accumulate)(ident, func, *args) ! # clear out old errors ! reset() ! ! if self.verbose: print "starting tasklet" ! t.run() ! self.assertEquals(is_empty(), True) ! # do we want to do this?? ! #t.tempval = None ! if self.verbose: print "pickling" ! pi = pickle.dumps(t) ! # if self.verbose: print repr(pi) ! # why do we want to remove it? ! # t.remove() ! ! if self.verbose: print "unpickling" ! ip = pickle.loads(pi) ! if self.verbose: print "starting unpickled tasklet" ! ip.run() ! new_ident, new_rval = get_result() ! t.run() ! old_ident, old_rval = get_result() ! self.assertEquals(old_ident, ident) ! self.assertEquals(new_rval, old_rval) ! self.assertNotEquals(new_ident, old_ident) ! self.assertEquals(is_empty(), True) ! # compatibility to 2.2.3 ! try: ! enumerate ! have_enumerate = True ! except NameError: ! have_enumerate = False ! try: ! {}.fromkeys ! have_fromkeys = True ! except AttributeError: ! have_fromkeys = False ! ! class TestConcretePickledTasklets(TestPickledTasklets): ! def testGenerator(self): ! self.run_pickled(genoutertest, 20, 13) ! def testList(self): ! self.run_pickled(listtest, 20, 13) ! def testXrange(self): ! self.run_pickled(xrangetest, 20, 13) ! def testRecursive(self): ! self.run_pickled(rectest, 13) ! if have_fromkeys: ! def testDict(self): ! self.run_pickled(dicttest, 20, 13) ! if have_enumerate: ! def testEnumerate(self): ! self.run_pickled(enumeratetest, 20, 13) ! def testTuple(self): ! self.run_pickled(tupletest, 20, 13) ! def testGeneratorScheduling(self): ! self.run_pickled(genschedoutertest, 20, 13) ! def testRecursiveLambda(self): ! recurse = lambda self, next: \ ! next-1 and self(self, next-1) or (schedule(), 42)[1] ! pickle.loads(pickle.dumps(recurse)) ! self.run_pickled(recurse, recurse, 13) ! ! def testRecursiveEmbedded(self): ! def rectest(nrec, lev=0): ! if self.verbose: print nrec, lev ! if lev < nrec: ! rectest(nrec, lev+1) ! else: ! schedule() ! self.run_pickled(rectest, 13) ! def testFakeModules(self): ! types.ModuleType('fakemodule!') --- 84,191 ---- return i + softswitch = stackless.enable_softswitch(0) + stackless.enable_softswitch(softswitch) ! if softswitch: ! class TestPickledTasklets(unittest.TestCase): ! def setUp(self): ! self.verbose = VERBOSE ! def tearDown(self): ! del self.verbose ! def run_pickled(self, func, *args): ! ident = object() ! t = tasklet(accumulate)(ident, func, *args) ! # clear out old errors ! reset() ! ! if self.verbose: print "starting tasklet" ! t.run() ! self.assertEquals(is_empty(), True) ! # do we want to do this?? ! #t.tempval = None ! if self.verbose: print "pickling" ! pi = pickle.dumps(t) ! # if self.verbose: print repr(pi) ! # why do we want to remove it? ! # t.remove() ! ! if self.verbose: print "unpickling" ! ip = pickle.loads(pi) ! if self.verbose: print "starting unpickled tasklet" ! ip.run() ! new_ident, new_rval = get_result() ! t.run() ! old_ident, old_rval = get_result() ! self.assertEquals(old_ident, ident) ! self.assertEquals(new_rval, old_rval) ! self.assertNotEquals(new_ident, old_ident) ! self.assertEquals(is_empty(), True) ! # compatibility to 2.2.3 ! try: ! enumerate ! have_enumerate = True ! except NameError: ! have_enumerate = False ! try: ! {}.fromkeys ! have_fromkeys = True ! except AttributeError: ! have_fromkeys = False ! ! class TestConcretePickledTasklets(TestPickledTasklets): ! def testGenerator(self): ! self.run_pickled(genoutertest, 20, 13) ! def testList(self): ! self.run_pickled(listtest, 20, 13) ! def testXrange(self): ! self.run_pickled(xrangetest, 20, 13) ! def testRecursive(self): ! self.run_pickled(rectest, 13) ! if have_fromkeys: ! def testDict(self): ! self.run_pickled(dicttest, 20, 13) ! if have_enumerate: ! def testEnumerate(self): ! self.run_pickled(enumeratetest, 20, 13) ! def testTuple(self): ! self.run_pickled(tupletest, 20, 13) ! def testGeneratorScheduling(self): ! self.run_pickled(genschedoutertest, 20, 13) ! def testRecursiveLambda(self): ! recurse = lambda self, next: \ ! next-1 and self(self, next-1) or (schedule(), 42)[1] ! pickle.loads(pickle.dumps(recurse)) ! self.run_pickled(recurse, recurse, 13) ! ! def testRecursiveEmbedded(self): ! def rectest(nrec, lev=0): ! if self.verbose: print nrec, lev ! if lev < nrec: ! rectest(nrec, lev+1) ! else: ! schedule() ! self.run_pickled(rectest, 13) ! def testFakeModules(self): ! types.ModuleType('fakemodule!') Index: test_watchdog.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/unittests/test_watchdog.py,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** test_watchdog.py 3 May 2004 16:53:39 -0000 1.6 --- test_watchdog.py 2 Jun 2004 23:03:43 -0000 1.7 *************** *** 5,8 **** --- 5,11 ---- # Helpers + softswitch = stackless.enable_softswitch(0) + stackless.enable_softswitch(softswitch) + class SimpleScheduler(object): """ Not really scheduler as such but used here to implement *************** *** 156,159 **** --- 159,164 ---- for name in ["t1", "t2", "t3"]: tasklets.append(stackless.tasklet(fn)(name)) + # allow scheduling with hard switching + map(lambda t:t.set_ignore_nesting(1), tasklets) scheduler.autoschedule() *************** *** 168,172 **** ! def test_recursion_count(self): self.run_tasklets(runtask6) --- 173,177 ---- ! def xtest_recursion_count(self): self.run_tasklets(runtask6) *************** *** 216,242 **** def test_atomic(self): self.run_tasklets(runtask_atomic) - def test_exception(self): self.failUnlessRaises(UserWarning, lambda:self.run_tasklets(runtask_bad)) - def get_pickled_tasklet(self): orig = stackless.tasklet(runtask_print)("pickleme") not_finished = stackless.run(100) self.assertEqual(not_finished, orig) return pickle.dumps(not_finished) ! ! def test_pickle(self): # Run global t = pickle.loads(self.get_pickled_tasklet()) t.insert() ! stackless.run() # Run on tasklet t = pickle.loads(self.get_pickled_tasklet()) t.insert() ! t.run() # Run on watchdog --- 221,252 ---- def test_atomic(self): self.run_tasklets(runtask_atomic) def test_exception(self): self.failUnlessRaises(UserWarning, lambda:self.run_tasklets(runtask_bad)) def get_pickled_tasklet(self): orig = stackless.tasklet(runtask_print)("pickleme") + orig.set_ignore_nesting(1) not_finished = stackless.run(100) self.assertEqual(not_finished, orig) return pickle.dumps(not_finished) ! def test_pickle(self): # Run global t = pickle.loads(self.get_pickled_tasklet()) t.insert() ! if softswitch: ! stackless.run() ! else: ! self.failUnlessRaises(RuntimeError, stackless.run) # Run on tasklet t = pickle.loads(self.get_pickled_tasklet()) t.insert() ! if softswitch: ! t.run() ! else: ! self.failUnlessRaises(RuntimeError, t.run) ! return # enough crap # Run on watchdog *************** *** 245,249 **** while stackless.runcount > 1: returned = stackless.run(100) - if __name__ == '__main__': --- 255,258 ---- _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sun Jun 6 15:58:17 2004 From: tismer at centera.de (Christian Tismer) Date: Sun, 06 Jun 2004 15:58:17 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core stacklesseval.c, 1.159, 1.160 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv27390/Stackless/core Modified Files: stacklesseval.c Log Message: solved a quite hard to find bug in cstack allocation. I think it is now time to publish Stackless 3.1 :-) Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.159 retrieving revision 1.160 diff -C2 -d -r1.159 -r1.160 *** a/stacklesseval.c 6 Jun 2004 13:15:44 -0000 1.159 --- b/stacklesseval.c 6 Jun 2004 13:58:14 -0000 1.160 *************** *** 56,60 **** stack = cstack_cache[i]; cstack_cache[i] = (PyCStackObject *) stack->startaddr; ! PyMem_Free(stack); } } --- 56,60 ---- stack = cstack_cache[i]; cstack_cache[i] = (PyCStackObject *) stack->startaddr; ! PyObject_Del(stack); } } *************** *** 69,77 **** prev); if (cst->ob_size >= CSTACK_SLOTS) { ! PyMem_Free(cst); } else { if (cstack_cachecount >= CSTACK_MAXCACHE) ! slp_cstack_cacheclear(); cst->startaddr = (int *) cstack_cache[cst->ob_size]; cstack_cache[cst->ob_size] = cst; --- 69,77 ---- prev); if (cst->ob_size >= CSTACK_SLOTS) { ! PyObject_Del(cst); } else { if (cstack_cachecount >= CSTACK_MAXCACHE) ! slp_cstack_cacheclear(); cst->startaddr = (int *) cstack_cache[cst->ob_size]; cstack_cache[cst->ob_size] = cst; *************** *** 88,100 **** int size = stackbase - stackref; ! if (size < 0) ! RUNTIME_ERROR("negative stack size", NULL); ! if (*cst && (*cst)->ob_size == size && (*cst)->ob_refcnt == 1) { ! /* reuse it */ ! (*cst)->task = task; ! printf("cstack new probable error, true=%d %d\n", ts->st.nesting_level, (*cst)->nesting_level); ! return *cst; ! } ! if (*cst != NULL) { if ((*cst)->task == task) --- 88,93 ---- int size = stackbase - stackref; ! assert(size >= 0); ! if (*cst != NULL) { if ((*cst)->task == task) *************** *** 106,118 **** cstack_cache[size] = (PyCStackObject *) (*cst)->startaddr; --cstack_cachecount; } ! else { ! /* PyObject_NewVar is inlined */ ! *cst = (PyCStackObject *) ! PyObject_MALLOC(sizeof(PyCStackObject) + ! (size-1) * sizeof(int*)); ! if (*cst == NULL) return NULL; ! } ! (void) PyObject_INIT_VAR(*cst, &PyCStack_Type, size); (*cst)->startaddr = stackbase; --- 99,107 ---- cstack_cache[size] = (PyCStackObject *) (*cst)->startaddr; --cstack_cachecount; + _Py_NewReference((PyObject *)(*cst)); } ! else ! *cst = PyObject_NewVar(PyCStackObject, &PyCStack_Type, size); ! if (*cst == NULL) return NULL; (*cst)->startaddr = stackbase; *************** *** 123,127 **** (*cst)->tstate = ts; (*cst)->nesting_level = ts->st.nesting_level; - printf("cstack new with %d\n", (*cst)->nesting_level); return *cst; } --- 112,115 ---- *************** *** 141,145 **** { cst->tstate->st.nesting_level = cst->nesting_level; - printf("cstack restore with %d\n", cst->nesting_level); /* mark task as no longer responsible for cstack instance */ cst->task = NULL; --- 129,132 ---- *************** *** 579,583 **** ++ts->st.nesting_level; - printf("dispatch ++ %d\n", ts->st.nesting_level); /* --- 566,569 ---- *************** *** 602,606 **** } --ts->st.nesting_level; - printf("dispatch -- %d\n", ts->st.nesting_level); /* see whether we need to trigger a pending interrupt */ /* note that an interrupt handler guarantees current to exist */ --- 588,591 ---- _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 14:19:16 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 14:19:16 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/unittests runAll.py, 1.4, 1.5 test_miscell.py, 1.5, 1.6 test_pickle.py, 1.11, 1.12 test_watchdog.py, 1.7, 1.8 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/unittests In directory centera.de:/tmp/cvs-serv6338/Stackless/unittests Modified Files: runAll.py test_miscell.py test_pickle.py test_watchdog.py Log Message: enhancements to the tests: they all run soft and hard. auto-scheduling now obeys schedlock. scheduler callback can raise an error, now. Index: runAll.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/unittests/runAll.py,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** runAll.py 2 Jun 2004 23:03:43 -0000 1.4 --- runAll.py 3 Jun 2004 12:19:13 -0000 1.5 *************** *** 23,28 **** for idx, filename in enumerate(glob.glob('test_*.py')): modname = os.path.splitext(os.path.basename(filename))[0] - if modname in sys.modules: - del sys.modules[modname] module = __import__(modname) tests = unittest.TestLoader().loadTestsFromModule(module) --- 23,26 ---- Index: test_miscell.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/unittests/test_miscell.py,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** test_miscell.py 2 Jun 2004 23:03:43 -0000 1.5 --- test_miscell.py 3 Jun 2004 12:19:13 -0000 1.6 *************** *** 5,10 **** import stackless ! softswitch = stackless.enable_softswitch(0) ! stackless.enable_softswitch(softswitch) def runtask(): --- 5,12 ---- import stackless ! def is_soft(): ! softswitch = stackless.enable_softswitch(0) ! stackless.enable_softswitch(softswitch) ! return softswitch def runtask(): *************** *** 59,69 **** t_new.insert() self.lifecycle(t_new) ! ! if not softswitch: del test_aliveness2 ! def test_aliveness3(self): """ Same as 1, but with a pickled run(slightly) tasklet. """ t = stackless.tasklet(runtask)() # Initial state - unrun --- 61,70 ---- t_new.insert() self.lifecycle(t_new) ! def test_aliveness3(self): """ Same as 1, but with a pickled run(slightly) tasklet. """ t = stackless.tasklet(runtask)() + t.set_ignore_nesting(1) # Initial state - unrun *************** *** 84,89 **** # Now save & load dumped = pickle.dumps(t) ! t_new = pickle.loads(dumped) ! # Remove and insert & swap names around a bit --- 85,89 ---- # Now save & load dumped = pickle.dumps(t) ! t_new = pickle.loads(dumped) # Remove and insert & swap names around a bit *************** *** 99,109 **** # Run to completion ! stackless.run() self.failIf(t.alive) self.failIf(t.scheduled) self.assertEquals(t.recursion_depth, 0) - - if not softswitch: del test_aliveness3 - #/////////////////////////////////////////////////////////////////////////////// --- 99,109 ---- # Run to completion ! if is_soft(): ! stackless.run() ! else: ! t.kill() self.failIf(t.alive) self.failIf(t.scheduled) self.assertEquals(t.recursion_depth, 0) #/////////////////////////////////////////////////////////////////////////////// Index: test_pickle.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/unittests/test_pickle.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** test_pickle.py 2 Jun 2004 23:03:43 -0000 1.11 --- test_pickle.py 3 Jun 2004 12:19:13 -0000 1.12 *************** *** 84,134 **** return i ! softswitch = stackless.enable_softswitch(0) ! stackless.enable_softswitch(softswitch) ! if softswitch: ! class TestPickledTasklets(unittest.TestCase): ! def setUp(self): ! self.verbose = VERBOSE ! def tearDown(self): ! del self.verbose ! def run_pickled(self, func, *args): ! ident = object() ! t = tasklet(accumulate)(ident, func, *args) ! # clear out old errors ! reset() ! ! if self.verbose: print "starting tasklet" ! t.run() ! self.assertEquals(is_empty(), True) ! # do we want to do this?? ! #t.tempval = None ! if self.verbose: print "pickling" ! pi = pickle.dumps(t) ! # if self.verbose: print repr(pi) ! # why do we want to remove it? ! # t.remove() ! ! if self.verbose: print "unpickling" ! ip = pickle.loads(pi) ! if self.verbose: print "starting unpickled tasklet" ip.run() ! new_ident, new_rval = get_result() ! t.run() ! old_ident, old_rval = get_result() ! self.assertEquals(old_ident, ident) ! self.assertEquals(new_rval, old_rval) ! self.assertNotEquals(new_ident, old_ident) ! self.assertEquals(is_empty(), True) # compatibility to 2.2.3 try: enumerate --- 84,140 ---- return i ! def is_soft(): ! softswitch = stackless.enable_softswitch(0) ! stackless.enable_softswitch(softswitch) ! return softswitch ! class TestPickledTasklets(unittest.TestCase): ! def setUp(self): ! self.verbose = VERBOSE ! def tearDown(self): ! del self.verbose ! def run_pickled(self, func, *args): ! ident = object() ! t = tasklet(accumulate)(ident, func, *args) ! # clear out old errors ! reset() ! ! if self.verbose: print "starting tasklet" ! t.run() ! self.assertEquals(is_empty(), True) ! # do we want to do this?? ! #t.tempval = None ! if self.verbose: print "pickling" ! pi = pickle.dumps(t) ! # if self.verbose: print repr(pi) ! # why do we want to remove it? ! # t.remove() ! ! if self.verbose: print "unpickling" ! ip = pickle.loads(pi) ! if self.verbose: print "starting unpickled tasklet" ! if is_soft(): ip.run() ! else: ! self.assertRaises(RuntimeError, ip.run) ! return ! new_ident, new_rval = get_result() ! t.run() ! old_ident, old_rval = get_result() ! self.assertEquals(old_ident, ident) ! self.assertEquals(new_rval, old_rval) ! self.assertNotEquals(new_ident, old_ident) ! self.assertEquals(is_empty(), True) # compatibility to 2.2.3 + global have_enumerate try: enumerate *************** *** 137,140 **** --- 143,147 ---- have_enumerate = False + global have_fromkeys try: {}.fromkeys *************** *** 142,191 **** except AttributeError: have_fromkeys = False - ! class TestConcretePickledTasklets(TestPickledTasklets): ! def testGenerator(self): ! self.run_pickled(genoutertest, 20, 13) ! def testList(self): ! self.run_pickled(listtest, 20, 13) ! def testXrange(self): ! self.run_pickled(xrangetest, 20, 13) ! def testRecursive(self): ! self.run_pickled(rectest, 13) ! if have_fromkeys: ! def testDict(self): ! self.run_pickled(dicttest, 20, 13) ! if have_enumerate: ! def testEnumerate(self): ! self.run_pickled(enumeratetest, 20, 13) ! def testTuple(self): ! self.run_pickled(tupletest, 20, 13) ! def testGeneratorScheduling(self): ! self.run_pickled(genschedoutertest, 20, 13) ! def testRecursiveLambda(self): ! recurse = lambda self, next: \ ! next-1 and self(self, next-1) or (schedule(), 42)[1] ! pickle.loads(pickle.dumps(recurse)) ! self.run_pickled(recurse, recurse, 13) ! ! def testRecursiveEmbedded(self): ! def rectest(nrec, lev=0): ! if self.verbose: print nrec, lev ! if lev < nrec: ! rectest(nrec, lev+1) ! else: ! schedule() ! self.run_pickled(rectest, 13) ! def testFakeModules(self): ! types.ModuleType('fakemodule!') --- 149,197 ---- except AttributeError: have_fromkeys = False ! class TestConcretePickledTasklets(TestPickledTasklets): ! def testGenerator(self): ! self.run_pickled(genoutertest, 20, 13) ! def testList(self): ! self.run_pickled(listtest, 20, 13) ! def testXrange(self): ! self.run_pickled(xrangetest, 20, 13) ! def testRecursive(self): ! self.run_pickled(rectest, 13) ! if have_fromkeys: ! def testDict(self): ! self.run_pickled(dicttest, 20, 13) ! if have_enumerate: ! def testEnumerate(self): ! self.run_pickled(enumeratetest, 20, 13) ! def testTuple(self): ! self.run_pickled(tupletest, 20, 13) ! def testGeneratorScheduling(self): ! self.run_pickled(genschedoutertest, 20, 13) ! def testRecursiveLambda(self): ! recurse = lambda self, next: \ ! next-1 and self(self, next-1) or (schedule(), 42)[1] ! pickle.loads(pickle.dumps(recurse)) ! self.run_pickled(recurse, recurse, 13) ! ! def testRecursiveEmbedded(self): ! def rectest(nrec, lev=0): ! if self.verbose: print nrec, lev ! if lev < nrec: ! rectest(nrec, lev+1) ! else: ! schedule() ! self.run_pickled(rectest, 13) ! def testFakeModules(self): ! types.ModuleType('fakemodule!') Index: test_watchdog.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/unittests/test_watchdog.py,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** test_watchdog.py 2 Jun 2004 23:03:43 -0000 1.7 --- test_watchdog.py 3 Jun 2004 12:19:13 -0000 1.8 *************** *** 5,10 **** # Helpers ! softswitch = stackless.enable_softswitch(0) ! stackless.enable_softswitch(softswitch) class SimpleScheduler(object): --- 5,12 ---- # Helpers ! def is_soft(): ! softswitch = stackless.enable_softswitch(0) ! stackless.enable_softswitch(softswitch) ! return softswitch class SimpleScheduler(object): *************** *** 236,240 **** t = pickle.loads(self.get_pickled_tasklet()) t.insert() ! if softswitch: stackless.run() else: --- 238,242 ---- t = pickle.loads(self.get_pickled_tasklet()) t.insert() ! if is_soft(): stackless.run() else: *************** *** 244,248 **** t = pickle.loads(self.get_pickled_tasklet()) t.insert() ! if softswitch: t.run() else: --- 246,250 ---- t = pickle.loads(self.get_pickled_tasklet()) t.insert() ! if is_soft(): t.run() else: _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 14:19:19 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 14:19:19 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core stackless_impl.h, 1.90, 1.91 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv6338/Stackless/core Modified Files: stackless_impl.h Log Message: enhancements to the tests: they all run soft and hard. auto-scheduling now obeys schedlock. scheduler callback can raise an error, now. Index: stackless_impl.h =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stackless_impl.h,v retrieving revision 1.90 retrieving revision 1.91 diff -C2 -d -r1.90 -r1.91 *** stackless_impl.h 2 Jun 2004 23:03:43 -0000 1.90 --- stackless_impl.h 3 Jun 2004 12:19:15 -0000 1.91 *************** *** 438,446 **** /* debugging/monitoring */ ! typedef void (slp_schedule_hook_func) (PyTaskletObject *from, PyTaskletObject *to); PyAPI_DATA(slp_schedule_hook_func) *_slp_schedule_fasthook; PyAPI_DATA(PyObject* ) _slp_schedule_hook; ! void slp_schedule_callback(PyTaskletObject *prev, PyTaskletObject *next); #include "stackless_api.h" --- 438,446 ---- /* debugging/monitoring */ ! typedef int (slp_schedule_hook_func) (PyTaskletObject *from, PyTaskletObject *to); PyAPI_DATA(slp_schedule_hook_func) *_slp_schedule_fasthook; PyAPI_DATA(PyObject* ) _slp_schedule_hook; ! int slp_schedule_callback(PyTaskletObject *prev, PyTaskletObject *next); #include "stackless_api.h" _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:03:46 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:03:46 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Python ceval.c, 1.87, 1.88 pythonrun.c, 1.21, 1.22 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Python In directory centera.de:/tmp/cvs-serv3004/Python Modified Files: ceval.c pythonrun.c Log Message: Stackless 3.1 almost ready. All tests are working, both Python and Stackless, both soft and hard switching. New features: channels are working cross-thread! Stack protection for eval_frame and pickling is complete. A couple of smallish features are missing: pickling of channels refuse running tasklets from foreign threads channel.transfer scheduling strategy cross-thread cframe pickling, get rid of invalid_exec funcs, instead use the missing cframe owner-tasklet pointer! add more tests! Index: ceval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Python/ceval.c,v retrieving revision 1.87 retrieving revision 1.88 diff -C2 -d -r1.87 -r1.88 *** ceval.c 24 May 2004 01:59:34 -0000 1.87 --- ceval.c 2 Jun 2004 23:03:42 -0000 1.88 *************** *** 291,300 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ - #ifdef STACKLESS - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */ - #else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - #endif 0, /* tp_doc */ (traverseproc)gen_traverse, /* tp_traverse */ --- 291,295 ---- *************** *** 315,318 **** --- 310,315 ---- }; + STACKLESS_DECLARE_METHOD(&PyGenerator_Type, tp_iternext) + #ifdef WITH_THREAD *************** *** 961,964 **** --- 958,963 ---- goto stackless_interrupt_call; } + /* hard switch, drop value */ + Py_DECREF(ires); } } Index: pythonrun.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Python/pythonrun.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** pythonrun.c 24 May 2004 01:59:34 -0000 1.21 --- pythonrun.c 2 Jun 2004 23:03:42 -0000 1.22 *************** *** 171,176 **** (void) PyThreadState_Swap(tstate); - _Py_ReadyTypes(); - #ifdef STACKLESS if (!_PyStackless_InitTypes()) { --- 171,174 ---- *************** *** 180,183 **** --- 178,183 ---- #endif + _Py_ReadyTypes(); + if (!_PyFrame_Init()) Py_FatalError("Py_Initialize: can't init frames"); _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sat Jun 5 22:02:13 2004 From: tismer at centera.de (Christian Tismer) Date: Sat, 05 Jun 2004 22:02:13 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Objects methodobject.c, 1.11, 1.12 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Objects In directory centera.de:/tmp/cvs-serv4561/Objects Modified Files: methodobject.c Log Message: still hunting a linux bug. Made sure that schedule_task_destruct will always do a soft switch. Index: methodobject.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/methodobject.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** a/methodobject.c 2 Jun 2004 23:03:42 -0000 1.11 --- b/methodobject.c 5 Jun 2004 20:02:07 -0000 1.12 *************** *** 76,82 **** PyCFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) { - #ifdef STACKLESS STACKLESS_GETARG(); - #endif PyCFunctionObject* f = (PyCFunctionObject*)func; PyCFunction meth = PyCFunction_GET_FUNCTION(func); --- 76,80 ---- _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sat Jun 5 22:02:13 2004 From: tismer at centera.de (Christian Tismer) Date: Sat, 05 Jun 2004 22:02:13 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/module scheduling.c, 1.102, 1.103 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/module In directory centera.de:/tmp/cvs-serv4561/Stackless/module Modified Files: scheduling.c Log Message: still hunting a linux bug. Made sure that schedule_task_destruct will always do a soft switch. Index: scheduling.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/scheduling.c,v retrieving revision 1.102 retrieving revision 1.103 diff -C2 -d -r1.102 -r1.103 *** a/scheduling.c 3 Jun 2004 12:23:13 -0000 1.102 --- b/scheduling.c 5 Jun 2004 20:02:10 -0000 1.103 *************** *** 894,897 **** --- 894,899 ---- /* we should have no nesting level */ assert(ts->st.nesting_level == 0); + /* even there is a (buggy) nesting, ensure soft switch */ + ts->st.nesting_level = 0; /* update what's not yet updated */ _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 19:18:08 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 19:18:08 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core slp_transfer.c, 1.23, 1.24 stackless_impl.h, 1.92, 1.93 stacklesseval.c, 1.152, 1.153 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv14794/Stackless/core Modified Files: slp_transfer.c stackless_impl.h stacklesseval.c Log Message: moved more things into slp_transfer.c, to prevend inlining and optimization (gcc 3.3.2 problem) Index: slp_transfer.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/slp_transfer.c,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** slp_transfer.c 3 Jun 2004 17:07:34 -0000 1.23 --- slp_transfer.c 3 Jun 2004 17:18:06 -0000 1.24 *************** *** 48,53 **** /* this function must be here, too, to prevend inlining */ ! int ! slp_make_initial_stub(void) { PyThreadState *ts = PyThreadState_GET(); --- 48,53 ---- /* this function must be here, too, to prevend inlining */ ! static int ! make_initial_stub(void) { PyThreadState *ts = PyThreadState_GET(); *************** *** 72,75 **** --- 72,134 ---- } + static PyObject * + climb_stack_and_eval_frame(PyFrameObject *f) + { + /* + * a similar case to climb_stack_and_transfer, + * but here we need to incorporate a gap in the + * stack into main and keep this gap on the stack. + * This way, initial_stub is always valid to be + * used to return to the main c stack. + */ + PyThreadState *ts = PyThreadState_GET(); + int probe; + int needed = &probe - ts->st.cstack_base; + /* in rare cases, the need might have vanished due to the recursion */ + int * goobledigoobs; + + if (needed > 0) { + goobledigoobs = alloca(needed * sizeof(int)); + if (goobledigoobs == NULL) + return NULL; + } + return slp_eval_frame(f); + } + + PyObject * + slp_eval_frame(PyFrameObject *f) + { + PyThreadState *ts = PyThreadState_GET(); + PyFrameObject *fprev = f->f_back; + int * stackref; + + if (fprev == NULL && ts->st.main == NULL) { + /* this is the initial frame, so mark the stack base */ + + /* + * careful, this caused me a major headache. + * it is *not* sufficient to just check for fprev == NULL. + * Reason: (observed with wxPython): + * A toplevel frame is run as a tasklet. When its frame + * is deallocated (in tasklet_end), a Python object + * with a __del__ method is destroyed. This __del__ + * will run as a toplevel frame, with f_back == NULL! + */ + + stackref = STACK_REFPLUS + (int*) &f; + if (ts->st.cstack_base == NULL) + ts->st.cstack_base = stackref-CSTACK_GOODGAP; + if (stackref > ts->st.cstack_base) + return climb_stack_and_eval_frame(f); + + ts->frame = f; + if (make_initial_stub()) + return NULL; + return slp_run_tasklet(); + } + Py_INCREF(Py_None); + return slp_frame_dispatch(f, fprev, Py_None); + } + static int climb_stack_and_transfer(PyCStackObject **cstprev, PyCStackObject *cst, Index: stackless_impl.h =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stackless_impl.h,v retrieving revision 1.92 retrieving revision 1.93 diff -C2 -d -r1.92 -r1.93 *** stackless_impl.h 3 Jun 2004 17:07:34 -0000 1.92 --- stackless_impl.h 3 Jun 2004 17:18:06 -0000 1.93 *************** *** 44,49 **** PyAPI_FUNC(void) slp_cstack_restore(PyCStackObject *cst); - PyAPI_FUNC(int) slp_make_initial_stub(void); - PyAPI_FUNC(int) slp_transfer(PyCStackObject **cstprev, PyCStackObject *cst, PyTaskletObject *prev); --- 44,47 ---- Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.152 retrieving revision 1.153 diff -C2 -d -r1.152 -r1.153 *** stacklesseval.c 3 Jun 2004 17:07:34 -0000 1.152 --- stacklesseval.c 3 Jun 2004 17:18:06 -0000 1.153 *************** *** 212,275 **** }; ! ! static PyObject * ! climb_stack_and_eval_frame(PyFrameObject *f) ! { ! /* ! * a similar case to climb_stack_and_transfer, ! * but here we need to incorporate a gap in the ! * stack into main and keep this gap on the stack. ! * This way, initial_stub is always valid to be ! * used to return to the main c stack. ! */ ! PyThreadState *ts = PyThreadState_GET(); ! int probe; ! int needed = &probe - ts->st.cstack_base; ! /* in rare cases, the need might have vanished due to the recursion */ ! int * goobledigoobs; ! ! if (needed > 0) { ! goobledigoobs = alloca(needed * sizeof(int)); ! if (goobledigoobs == NULL) ! return NULL; ! } ! return slp_eval_frame(f); ! } ! ! ! PyObject * ! slp_eval_frame(PyFrameObject *f) ! { ! PyThreadState *ts = PyThreadState_GET(); ! PyFrameObject *fprev = f->f_back; ! int * stackref; ! ! if (fprev == NULL && ts->st.main == NULL) { ! /* this is the initial frame, so mark the stack base */ ! ! /* ! * careful, this caused me a major headache. ! * it is *not* sufficient to just check for fprev == NULL. ! * Reason: (observed with wxPython): ! * A toplevel frame is run as a tasklet. When its frame ! * is deallocated (in tasklet_end), a Python object ! * with a __del__ method is destroyed. This __del__ ! * will run as a toplevel frame, with f_back == NULL! ! */ ! ! stackref = STACK_REFPLUS + (int*) &f; ! if (ts->st.cstack_base == NULL) ! ts->st.cstack_base = stackref-CSTACK_GOODGAP; ! if (stackref > ts->st.cstack_base) ! return climb_stack_and_eval_frame(f); ! ! ts->frame = f; ! if (slp_make_initial_stub()) ! return NULL; ! return slp_run_tasklet(); ! } ! Py_INCREF(Py_None); ! return slp_frame_dispatch(f, fprev, Py_None); ! } void slp_kill_tasks_with_stacks(PyThreadState *ts) --- 212,219 ---- }; ! /* ! * slp_eval_frame moved to slp_transfer.c ! * to avoid optimization in gcc 3.3.2 ! */ void slp_kill_tasks_with_stacks(PyThreadState *ts) _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 19:07:36 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 19:07:36 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/module taskletobject.c, 1.114, 1.115 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/module In directory centera.de:/tmp/cvs-serv6819/Stackless/module Modified Files: taskletobject.c Log Message: moved initial stub creation ibnto slp_transfer.c, to prevend inlining (gcc 3.3.2 problem) Index: taskletobject.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/taskletobject.c,v retrieving revision 1.114 retrieving revision 1.115 diff -C2 -d -r1.114 -r1.115 *** taskletobject.c 24 May 2004 01:45:38 -0000 1.114 --- taskletobject.c 3 Jun 2004 17:07:34 -0000 1.115 *************** *** 716,720 **** slp_current_remove(); /* reference used in tempval */ TASKLET_SETVAL_OWN(self, parent); ! TASKLET_SETVAL_OWN(parent, retval); /* comsume it */ ret = slp_schedule_task(parent, self, 1); return ret; --- 716,720 ---- slp_current_remove(); /* reference used in tempval */ TASKLET_SETVAL_OWN(self, parent); ! TASKLET_SETVAL_OWN(parent, retval); /* consume it */ ret = slp_schedule_task(parent, self, 1); return ret; _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Tue Jun 29 17:43:00 2004 From: tismer at centera.de (Christian Tismer) Date: Tue, 29 Jun 2004 17:43:00 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/bzip2-1.0.2 CHANGES, NONE, 1.1 LICENSE, NONE, 1.1 Makefile, NONE, 1.1 Makefile-libbz2_so, NONE, 1.1 README, NONE, 1.1 README.COMPILATION.PROBLEMS, NONE, 1.1 Y2K_INFO, NONE, 1.1 blocksort.c, NONE, 1.1 bzdiff, NONE, 1.1 bzdiff.1, NONE, 1.1 bzgrep, NONE, 1.1 bzgrep.1, NONE, 1.1 bzip2.1, NONE, 1.1 bzip2.1.preformatted, NONE, 1.1 bzip2.c, NONE, 1.1 bzip2.txt, NONE, 1.1 bzip2recover.c, NONE, 1.1 bzlib.c, NONE, 1.1 bzlib.h, NONE, 1.1 bzlib_private.h, NONE, 1.1 bzmore, NONE, 1.1 bzmore.1, NONE, 1.1 compress.c, NONE, 1.1 crctable.c, NONE, 1.1 decompress.c, NONE, 1.1 dlltest.c, NONE, 1.1 dlltest.dsp, NONE, 1.1 huffman.c, NONE, 1.1 libbz2.001, NONE, 1.1 libbz2.dsp, NONE, 1.1 libbz2.dsw, NONE, 1.1 makefile.msc, NONE, 1.1 manual.html, NONE, 1.1 manual.pdf, NONE, 1.1 manual.ps, NONE, 1.1 manual.texi, NONE, 1.1 manual_1.html, NONE, 1.1 manual_2.html, NONE, 1.1 manual_3.html, NONE, 1.1 manual_4.html, NONE, 1.1 manual_abt.html, NONE, 1.1 manual_ovr.html, NONE, 1.1 manual_toc.html, NONE, 1.1 mk251.c, NONE, 1.1 randtable.c, NONE, 1.1 sample1.bz2, NONE, 1.1 sample1.ref, NONE, 1.1 sample2.bz2, NONE, 1.1 sample2.ref, NONE, 1.1 sample3.bz2, NONE, 1.1 sample3.ref, NONE, 1.1 spewG.c, NONE, 1.1 unzcrash.c, NONE, 1.1 words0, NONE, 1.1 words1, NONE, 1.1 words2, NONE, 1.1 words3, NONE, 1.1 Message-ID: Update of /home/cvs/slpdev/src/2.3/bzip2-1.0.2 In directory centera.de:/tmp/cvs-serv886 Added Files: CHANGES LICENSE Makefile Makefile-libbz2_so README README.COMPILATION.PROBLEMS Y2K_INFO blocksort.c bzdiff bzdiff.1 bzgrep bzgrep.1 bzip2.1 bzip2.1.preformatted bzip2.c bzip2.txt bzip2recover.c bzlib.c bzlib.h bzlib_private.h bzmore bzmore.1 compress.c crctable.c decompress.c dlltest.c dlltest.dsp huffman.c libbz2.001 libbz2.dsp libbz2.dsw makefile.msc manual.html manual.pdf manual.ps manual.texi manual_1.html manual_2.html manual_3.html manual_4.html manual_abt.html manual_ovr.html manual_toc.html mk251.c randtable.c sample1.bz2 sample1.ref sample2.bz2 sample2.ref sample3.bz2 sample3.ref spewG.c unzcrash.c words0 words1 words2 words3 Log Message: added bzip2 to stackless lib --- NEW FILE: CHANGES --- 0.9.0 ~~~~~ First version. 0.9.0a ~~~~~~ Removed 'ranlib' from Makefile, since most modern Unix-es don't need it, or even know about it. 0.9.0b ~~~~~~ Fixed a problem with error reporting in bzip2.c. This does not effect the library in any way. Problem is: versions 0.9.0 and 0.9.0a (of the program proper) compress and decompress correctly, but give misleading error messages (internal panics) when an I/O error occurs, instead of reporting the problem correctly. This shouldn't give any data loss (as far as I can see), but is confusing. Made the inline declarations disappear for non-GCC compilers. 0.9.0c ~~~~~~ Fixed some problems in the library pertaining to some boundary cases. This makes the library behave more correctly in those situations. The fixes apply only to features (calls and parameters) not used by bzip2.c, so the non-fixedness of them in previous versions has no effect on reliability of bzip2.c. In bzlib.c: * made zero-length BZ_FLUSH work correctly in bzCompress(). * fixed bzWrite/bzRead to ignore zero-length requests. * fixed bzread to correctly handle read requests after EOF. * wrong parameter order in call to bzDecompressInit in bzBuffToBuffDecompress. Fixed. In compress.c: * changed setting of nGroups in sendMTFValues() so as to do a bit better on small files. This _does_ effect bzip2.c. 0.9.5a ~~~~~~ Major change: add a fallback sorting algorithm (blocksort.c) to give reasonable behaviour even for very repetitive inputs. Nuked --repetitive-best and --repetitive-fast since they are no longer useful. Minor changes: mostly a whole bunch of small changes/ bugfixes in the driver (bzip2.c). Changes pertaining to the user interface are: allow decompression of symlink'd files to stdout decompress/test files even without .bz2 extension give more accurate error messages for I/O errors when compressing/decompressing to stdout, don't catch control-C read flags from BZIP2 and BZIP environment variables decline to break hard links to a file unless forced with -f allow -c flag even with no filenames preserve file ownerships as far as possible make -s -1 give the expected block size (100k) add a flag -q --quiet to suppress nonessential warnings stop decoding flags after --, so files beginning in - can be handled resolved inconsistent naming: bzcat or bz2cat ? bzip2 --help now returns 0 Programming-level changes are: fixed syntax error in GET_LL4 for Borland C++ 5.02 let bzBuffToBuffDecompress return BZ_DATA_ERROR{_MAGIC} fix overshoot of mode-string end in bzopen_or_bzdopen wrapped bzlib.h in #ifdef __cplusplus ... extern "C" { ... } close file handles under all error conditions added minor mods so it compiles with DJGPP out of the box fixed Makefile so it doesn't give problems with BSD make fix uninitialised memory reads in dlltest.c 0.9.5b ~~~~~~ Open stdin/stdout in binary mode for DJGPP. 0.9.5c ~~~~~~ Changed BZ_N_OVERSHOOT to be ... + 2 instead of ... + 1. The + 1 version could cause the sorted order to be wrong in some extremely obscure cases. Also changed setting of quadrant in blocksort.c. 0.9.5d ~~~~~~ The only functional change is to make bzlibVersion() in the library return the correct string. This has no effect whatsoever on the functioning of the bzip2 program or library. Added a couple of casts so the library compiles without warnings at level 3 in MS Visual Studio 6.0. Included a Y2K statement in the file Y2K_INFO. All other changes are minor documentation changes. 1.0 ~~~ Several minor bugfixes and enhancements: * Large file support. The library uses 64-bit counters to count the volume of data passing through it. bzip2.c is now compiled with -D_FILE_OFFSET_BITS=64 to get large file support from the C library. -v correctly prints out file sizes greater than 4 gigabytes. All these changes have been made without assuming a 64-bit platform or a C compiler which supports 64-bit ints, so, except for the C library aspect, they are fully portable. * Decompression robustness. The library/program should be robust to any corruption of compressed data, detecting and handling _all_ corruption, instead of merely relying on the CRCs. What this means is that the program should never crash, given corrupted data, and the library should always return BZ_DATA_ERROR. * Fixed an obscure race-condition bug only ever observed on Solaris, in which, if you were very unlucky and issued control-C at exactly the wrong time, both input and output files would be deleted. * Don't run out of file handles on test/decompression when large numbers of files have invalid magic numbers. * Avoid library namespace pollution. Prefix all exported symbols with BZ2_. * Minor sorting enhancements from my DCC2000 paper. * Advance the version number to 1.0, so as to counteract the (false-in-this-case) impression some people have that programs with version numbers less than 1.0 are in some way, experimental, pre-release versions. * Create an initial Makefile-libbz2_so to build a shared library. Yes, I know I should really use libtool et al ... * Make the program exit with 2 instead of 0 when decompression fails due to a bad magic number (ie, an invalid bzip2 header). Also exit with 1 (as the manual claims :-) whenever a diagnostic message would have been printed AND the corresponding operation is aborted, for example bzip2: Output file xx already exists. When a diagnostic message is printed but the operation is not aborted, for example bzip2: Can't guess original name for wurble -- using wurble.out then the exit value 0 is returned, unless some other problem is also detected. I think it corresponds more closely to what the manual claims now. 1.0.1 ~~~~~ * Modified dlltest.c so it uses the new BZ2_ naming scheme. * Modified makefile-msc to fix minor build probs on Win2k. * Updated README.COMPILATION.PROBLEMS. There are no functionality changes or bug fixes relative to version 1.0.0. This is just a documentation update + a fix for minor Win32 build problems. For almost everyone, upgrading from 1.0.0 to 1.0.1 is utterly pointless. Don't bother. 1.0.2 ~~~~~ A bug fix release, addressing various minor issues which have appeared in the 18 or so months since 1.0.1 was released. Most of the fixes are to do with file-handling or documentation bugs. To the best of my knowledge, there have been no data-loss-causing bugs reported in the compression/decompression engine of 1.0.0 or 1.0.1. Note that this release does not improve the rather crude build system for Unix platforms. The general plan here is to autoconfiscate/ libtoolise 1.0.2 soon after release, and release the result as 1.1.0 or perhaps 1.2.0. That, however, is still just a plan at this point. Here are the changes in 1.0.2. Bug-reporters and/or patch-senders in parentheses. * Fix an infinite segfault loop in 1.0.1 when a directory is encountered in -f (force) mode. (Trond Eivind Glomsrod, Nicholas Nethercote, Volker Schmidt) * Avoid double fclose() of output file on certain I/O error paths. (Solar Designer) * Don't fail with internal error 1007 when fed a long stream (> 48MB) of byte 251. Also print useful message suggesting that 1007s may be caused by bad memory. (noticed by Juan Pedro Vallejo, fixed by me) * Fix uninitialised variable silly bug in demo prog dlltest.c. (Jorj Bauer) * Remove 512-MB limitation on recovered file size for bzip2recover on selected platforms which support 64-bit ints. At the moment all GCC supported platforms, and Win32. (me, Alson van der Meulen) * Hard-code header byte values, to give correct operation on platforms using EBCDIC as their native character set (IBM's OS/390). (Leland Lucius) * Copy file access times correctly. (Marty Leisner) * Add distclean and check targets to Makefile. (Michael Carmack) * Parameterise use of ar and ranlib in Makefile. Also add $(LDFLAGS). (Rich Ireland, Bo Thorsen) * Pass -p (create parent dirs as needed) to mkdir during make install. (Jeremy Fusco) * Dereference symlinks when copying file permissions in -f mode. (Volker Schmidt) * Majorly simplify implementation of uInt64_qrm10. (Bo Lindbergh) * Check the input file still exists before deleting the output one, when aborting in cleanUpAndFail(). (Joerg Prante, Robert Linden, Matthias Krings) Also a bunch of patches courtesy of Philippe Troin, the Debian maintainer of bzip2: * Wrapper scripts (with manpages): bzdiff, bzgrep, bzmore. * Spelling changes and minor enhancements in bzip2.1. * Avoid race condition between creating the output file and setting its interim permissions safely, by using fopen_output_safely(). No changes to bzip2recover since there is no issue with file permissions there. * do not print senseless report with -v when compressing an empty file. * bzcat -f works on non-bzip2 files. * do not try to escape shell meta-characters on unix (the shell takes care of these). * added --fast and --best aliases for -1 -9 for gzip compatibility. --- NEW FILE: LICENSE --- This program, "bzip2" and associated library "libbzip2", are copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. jseward at acm.org bzip2/libbzip2 version 1.0.2 of 30 December 2001 --- NEW FILE: Makefile --- SHELL=/bin/sh # To assist in cross-compiling CC=gcc AR=ar RANLIB=ranlib LDFLAGS= # Suitably paranoid flags to avoid bugs in gcc-2.7 BIGFILES=-D_FILE_OFFSET_BITS=64 CFLAGS=-Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce $(BIGFILES) # Where you want it installed when you do 'make install' PREFIX=/usr OBJS= blocksort.o \ huffman.o \ crctable.o \ randtable.o \ compress.o \ decompress.o \ bzlib.o all: libbz2.a bzip2 bzip2recover test bzip2: libbz2.a bzip2.o $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2 bzip2.o -L. -lbz2 bzip2recover: bzip2recover.o $(CC) $(CFLAGS) $(LDFLAGS) -o bzip2recover bzip2recover.o libbz2.a: $(OBJS) rm -f libbz2.a $(AR) cq libbz2.a $(OBJS) @if ( test -f $(RANLIB) -o -f /usr/bin/ranlib -o \ -f /bin/ranlib -o -f /usr/ccs/bin/ranlib ) ; then \ echo $(RANLIB) libbz2.a ; \ $(RANLIB) libbz2.a ; \ fi check: test test: bzip2 @cat words1 ./bzip2 -1 < sample1.ref > sample1.rb2 ./bzip2 -2 < sample2.ref > sample2.rb2 ./bzip2 -3 < sample3.ref > sample3.rb2 ./bzip2 -d < sample1.bz2 > sample1.tst ./bzip2 -d < sample2.bz2 > sample2.tst ./bzip2 -ds < sample3.bz2 > sample3.tst cmp sample1.bz2 sample1.rb2 cmp sample2.bz2 sample2.rb2 cmp sample3.bz2 sample3.rb2 cmp sample1.tst sample1.ref cmp sample2.tst sample2.ref cmp sample3.tst sample3.ref @cat words3 install: bzip2 bzip2recover if ( test ! -d $(PREFIX)/bin ) ; then mkdir -p $(PREFIX)/bin ; fi if ( test ! -d $(PREFIX)/lib ) ; then mkdir -p $(PREFIX)/lib ; fi if ( test ! -d $(PREFIX)/man ) ; then mkdir -p $(PREFIX)/man ; fi if ( test ! -d $(PREFIX)/man/man1 ) ; then mkdir -p $(PREFIX)/man/man1 ; fi if ( test ! -d $(PREFIX)/include ) ; then mkdir -p $(PREFIX)/include ; fi cp -f bzip2 $(PREFIX)/bin/bzip2 cp -f bzip2 $(PREFIX)/bin/bunzip2 cp -f bzip2 $(PREFIX)/bin/bzcat cp -f bzip2recover $(PREFIX)/bin/bzip2recover chmod a+x $(PREFIX)/bin/bzip2 chmod a+x $(PREFIX)/bin/bunzip2 chmod a+x $(PREFIX)/bin/bzcat chmod a+x $(PREFIX)/bin/bzip2recover cp -f bzip2.1 $(PREFIX)/man/man1 chmod a+r $(PREFIX)/man/man1/bzip2.1 cp -f bzlib.h $(PREFIX)/include chmod a+r $(PREFIX)/include/bzlib.h cp -f libbz2.a $(PREFIX)/lib chmod a+r $(PREFIX)/lib/libbz2.a cp -f bzgrep $(PREFIX)/bin/bzgrep ln $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzegrep ln $(PREFIX)/bin/bzgrep $(PREFIX)/bin/bzfgrep chmod a+x $(PREFIX)/bin/bzgrep cp -f bzmore $(PREFIX)/bin/bzmore ln $(PREFIX)/bin/bzmore $(PREFIX)/bin/bzless chmod a+x $(PREFIX)/bin/bzmore cp -f bzdiff $(PREFIX)/bin/bzdiff ln $(PREFIX)/bin/bzdiff $(PREFIX)/bin/bzcmp chmod a+x $(PREFIX)/bin/bzdiff cp -f bzgrep.1 bzmore.1 bzdiff.1 $(PREFIX)/man/man1 chmod a+r $(PREFIX)/man/man1/bzgrep.1 chmod a+r $(PREFIX)/man/man1/bzmore.1 chmod a+r $(PREFIX)/man/man1/bzdiff.1 echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzegrep.1 echo ".so man1/bzgrep.1" > $(PREFIX)/man/man1/bzfgrep.1 echo ".so man1/bzmore.1" > $(PREFIX)/man/man1/bzless.1 echo ".so man1/bzdiff.1" > $(PREFIX)/man/man1/bzcmp.1 distclean: clean clean: rm -f *.o libbz2.a bzip2 bzip2recover \ sample1.rb2 sample2.rb2 sample3.rb2 \ sample1.tst sample2.tst sample3.tst blocksort.o: blocksort.c @cat words0 $(CC) $(CFLAGS) -c blocksort.c huffman.o: huffman.c $(CC) $(CFLAGS) -c huffman.c crctable.o: crctable.c $(CC) $(CFLAGS) -c crctable.c randtable.o: randtable.c $(CC) $(CFLAGS) -c randtable.c compress.o: compress.c $(CC) $(CFLAGS) -c compress.c decompress.o: decompress.c $(CC) $(CFLAGS) -c decompress.c bzlib.o: bzlib.c $(CC) $(CFLAGS) -c bzlib.c bzip2.o: bzip2.c $(CC) $(CFLAGS) -c bzip2.c bzip2recover.o: bzip2recover.c $(CC) $(CFLAGS) -c bzip2recover.c DISTNAME=bzip2-1.0.2 tarfile: rm -f $(DISTNAME) ln -sf . $(DISTNAME) tar cvf $(DISTNAME).tar \ $(DISTNAME)/blocksort.c \ $(DISTNAME)/huffman.c \ $(DISTNAME)/crctable.c \ $(DISTNAME)/randtable.c \ $(DISTNAME)/compress.c \ $(DISTNAME)/decompress.c \ $(DISTNAME)/bzlib.c \ $(DISTNAME)/bzip2.c \ $(DISTNAME)/bzip2recover.c \ $(DISTNAME)/bzlib.h \ $(DISTNAME)/bzlib_private.h \ $(DISTNAME)/Makefile \ $(DISTNAME)/manual.texi \ $(DISTNAME)/manual.ps \ $(DISTNAME)/manual.pdf \ $(DISTNAME)/LICENSE \ $(DISTNAME)/bzip2.1 \ $(DISTNAME)/bzip2.1.preformatted \ $(DISTNAME)/bzip2.txt \ $(DISTNAME)/words0 \ $(DISTNAME)/words1 \ $(DISTNAME)/words2 \ $(DISTNAME)/words3 \ $(DISTNAME)/sample1.ref \ $(DISTNAME)/sample2.ref \ $(DISTNAME)/sample3.ref \ $(DISTNAME)/sample1.bz2 \ $(DISTNAME)/sample2.bz2 \ $(DISTNAME)/sample3.bz2 \ $(DISTNAME)/dlltest.c \ $(DISTNAME)/*.html \ $(DISTNAME)/README \ $(DISTNAME)/README.COMPILATION.PROBLEMS \ $(DISTNAME)/CHANGES \ $(DISTNAME)/libbz2.def \ $(DISTNAME)/libbz2.dsp \ $(DISTNAME)/dlltest.dsp \ $(DISTNAME)/makefile.msc \ $(DISTNAME)/Y2K_INFO \ $(DISTNAME)/unzcrash.c \ $(DISTNAME)/spewG.c \ $(DISTNAME)/mk251.c \ $(DISTNAME)/bzdiff \ $(DISTNAME)/bzdiff.1 \ $(DISTNAME)/bzmore \ $(DISTNAME)/bzmore.1 \ $(DISTNAME)/bzgrep \ $(DISTNAME)/bzgrep.1 \ $(DISTNAME)/Makefile-libbz2_so gzip -v $(DISTNAME).tar # For rebuilding the manual from sources on my RedHat 7.2 box manual: manual.ps manual.pdf manual.html manual.ps: manual.texi tex manual.texi dvips -o manual.ps manual.dvi manual.pdf: manual.ps ps2pdf manual.ps manual.html: manual.texi texi2html -split_chapter manual.texi --- NEW FILE: Makefile-libbz2_so --- # This Makefile builds a shared version of the library, # libbz2.so.1.0.2, with soname libbz2.so.1.0, # at least on x86-Linux (RedHat 7.2), # with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98). # Please see the README file for some # important info about building the library like this. SHELL=/bin/sh CC=gcc BIGFILES=-D_FILE_OFFSET_BITS=64 CFLAGS=-fpic -fPIC -Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce $(BIGFILES) OBJS= blocksort.o \ huffman.o \ crctable.o \ randtable.o \ compress.o \ decompress.o \ bzlib.o all: $(OBJS) $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.2 $(OBJS) $(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.2 rm -f libbz2.so.1.0 ln -s libbz2.so.1.0.2 libbz2.so.1.0 clean: rm -f $(OBJS) bzip2.o libbz2.so.1.0.2 libbz2.so.1.0 bzip2-shared blocksort.o: blocksort.c $(CC) $(CFLAGS) -c blocksort.c huffman.o: huffman.c $(CC) $(CFLAGS) -c huffman.c crctable.o: crctable.c $(CC) $(CFLAGS) -c crctable.c randtable.o: randtable.c $(CC) $(CFLAGS) -c randtable.c compress.o: compress.c $(CC) $(CFLAGS) -c compress.c decompress.o: decompress.c $(CC) $(CFLAGS) -c decompress.c bzlib.o: bzlib.c $(CC) $(CFLAGS) -c bzlib.c --- NEW FILE: README --- This is the README for bzip2, a block-sorting file compressor, version 1.0.2. This version is fully compatible with the previous public releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0 and 1.0.1. bzip2-1.0.2 is distributed under a BSD-style license. For details, see the file LICENSE. Complete documentation is available in Postscript form (manual.ps), PDF (manual.pdf, amazingly enough) or html (manual_toc.html). A plain-text version of the manual page is available as bzip2.txt. A statement about Y2K issues is now included in the file Y2K_INFO. HOW TO BUILD -- UNIX Type `make'. This builds the library libbz2.a and then the programs bzip2 and bzip2recover. Six self-tests are run. If the self-tests complete ok, carry on to installation: To install in /usr/bin, /usr/lib, /usr/man and /usr/include, type make install To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type make install PREFIX=/xxx/yyy If you are (justifiably) paranoid and want to see what 'make install' is going to do, you can first do make -n install or make -n install PREFIX=/xxx/yyy respectively. The -n instructs make to show the commands it would execute, but not actually execute them. HOW TO BUILD -- UNIX, shared library libbz2.so. Do 'make -f Makefile-libbz2_so'. This Makefile seems to work for Linux-ELF (RedHat 7.2 on an x86 box), with gcc. I make no claims that it works for any other platform, though I suspect it probably will work for most platforms employing both ELF and gcc. bzip2-shared, a client of the shared library, is also built, but not self-tested. So I suggest you also build using the normal Makefile, since that conducts a self-test. A second reason to prefer the version statically linked to the library is that, on x86 platforms, building shared objects makes a valuable register (%ebx) unavailable to gcc, resulting in a slowdown of 10%-20%, at least for bzip2. Important note for people upgrading .so's from 0.9.0/0.9.5 to version 1.0.X. All the functions in the library have been renamed, from (eg) bzCompress to BZ2_bzCompress, to avoid namespace pollution. Unfortunately this means that the libbz2.so created by Makefile-libbz2_so will not work with any program which used an older version of the library. Sorry. I do encourage library clients to make the effort to upgrade to use version 1.0, since it is both faster and more robust than previous versions. HOW TO BUILD -- Windows 95, NT, DOS, Mac, etc. It's difficult for me to support compilation on all these platforms. My approach is to collect binaries for these platforms, and put them on the master web page (http://sources.redhat.com/bzip2). Look there. However (FWIW), bzip2-1.0.X is very standard ANSI C and should compile unmodified with MS Visual C. If you have difficulties building, you might want to read README.COMPILATION.PROBLEMS. At least using MS Visual C++ 6, you can build from the unmodified sources by issuing, in a command shell: nmake -f makefile.msc (you may need to first run the MSVC-provided script VCVARS32.BAT so as to set up paths to the MSVC tools correctly). VALIDATION Correct operation, in the sense that a compressed file can always be decompressed to reproduce the original, is obviously of paramount importance. To validate bzip2, I used a modified version of Mark Nelson's churn program. Churn is an automated test driver which recursively traverses a directory structure, using bzip2 to compress and then decompress each file it encounters, and checking that the decompressed data is the same as the original. There are more details in Section 4 of the user guide. Please read and be aware of the following: WARNING: This program (attempts to) compress data by performing several non-trivial transformations on it. Unless you are 100% familiar with *all* the algorithms contained herein, and with the consequences of modifying them, you should NOT meddle with the compression or decompression machinery. Incorrect changes can and very likely *will* lead to disastrous loss of data. DISCLAIMER: I TAKE NO RESPONSIBILITY FOR ANY LOSS OF DATA ARISING FROM THE USE OF THIS PROGRAM, HOWSOEVER CAUSED. Every compression of a file implies an assumption that the compressed file can be decompressed to reproduce the original. Great efforts in design, coding and testing have been made to ensure that this program works correctly. However, the complexity of the algorithms, and, in particular, the presence of various special cases in the code which occur with very low but non-zero probability make it impossible to rule out the possibility of bugs remaining in the program. DO NOT COMPRESS ANY DATA WITH THIS PROGRAM UNLESS YOU ARE PREPARED TO ACCEPT THE POSSIBILITY, HOWEVER SMALL, THAT THE DATA WILL NOT BE RECOVERABLE. That is not to say this program is inherently unreliable. Indeed, I very much hope the opposite is true. bzip2 has been carefully constructed and extensively tested. PATENTS: To the best of my knowledge, bzip2 does not use any patented algorithms. However, I do not have the resources available to carry out a full patent search. Therefore I cannot give any guarantee of the above statement. End of legalities. WHAT'S NEW IN 0.9.0 (as compared to 0.1pl2) ? * Approx 10% faster compression, 30% faster decompression * -t (test mode) is a lot quicker * Can decompress concatenated compressed files * Programming interface, so programs can directly read/write .bz2 files * Less restrictive (BSD-style) licensing * Flag handling more compatible with GNU gzip * Much more documentation, i.e., a proper user manual * Hopefully, improved portability (at least of the library) WHAT'S NEW IN 0.9.5 ? * Compression speed is much less sensitive to the input data than in previous versions. Specifically, the very slow performance caused by repetitive data is fixed. * Many small improvements in file and flag handling. * A Y2K statement. WHAT'S NEW IN 1.0.0 ? See the CHANGES file. WHAT'S NEW IN 1.0.2 ? See the CHANGES file. I hope you find bzip2 useful. Feel free to contact me at jseward at acm.org if you have any suggestions or queries. Many people mailed me with comments, suggestions and patches after the releases of bzip-0.15, bzip-0.21, and bzip2 versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0 and 1.0.1, and the changes in bzip2 are largely a result of this feedback. I thank you for your comments. At least for the time being, bzip2's "home" is (or can be reached via) http://sources.redhat.com/bzip2. Julian Seward jseward at acm.org Cambridge, UK (and what a great town this is!) 18 July 1996 (version 0.15) 25 August 1996 (version 0.21) 7 August 1997 (bzip2, version 0.1) 29 August 1997 (bzip2, version 0.1pl2) 23 August 1998 (bzip2, version 0.9.0) 8 June 1999 (bzip2, version 0.9.5) 4 Sept 1999 (bzip2, version 0.9.5d) 5 May 2000 (bzip2, version 1.0pre8) 30 December 2001 (bzip2, version 1.0.2pre1) --- NEW FILE: README.COMPILATION.PROBLEMS --- bzip2-1.0 should compile without problems on the vast majority of platforms. Using the supplied Makefile, I've built and tested it myself for x86-linux, sparc-solaris, alpha-linux, x86-cygwin32 and alpha-tru64unix. With makefile.msc, Visual C++ 6.0 and nmake, you can build a native Win32 version too. Large file support seems to work correctly on at least alpha-tru64unix and x86-cygwin32 (on Windows 2000). When I say "large file" I mean a file of size 2,147,483,648 (2^31) bytes or above. Many older OSs can't handle files above this size, but many newer ones can. Large files are pretty huge -- most files you'll encounter are not Large Files. Earlier versions of bzip2 (0.1, 0.9.0, 0.9.5) compiled on a wide variety of platforms without difficulty, and I hope this version will continue in that tradition. However, in order to support large files, I've had to include the define -D_FILE_OFFSET_BITS=64 in the Makefile. This can cause problems. The technique of adding -D_FILE_OFFSET_BITS=64 to get large file support is, as far as I know, the Recommended Way to get correct large file support. For more details, see the Large File Support Specification, published by the Large File Summit, at http://www.sas.com/standard/large.file/ As a general comment, if you get compilation errors which you think are related to large file support, try removing the above define from the Makefile, ie, delete the line BIGFILES=-D_FILE_OFFSET_BITS=64 from the Makefile, and do 'make clean ; make'. This will give you a version of bzip2 without large file support, which, for most applications, is probably not a problem. Alternatively, try some of the platform-specific hints listed below. You can use the spewG.c program to generate huge files to test bzip2's large file support, if you are feeling paranoid. Be aware though that any compilation problems which affect bzip2 will also affect spewG.c, alas. Known problems as of 1.0pre8: ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ * HP/UX 10.20 and 11.00, using gcc (2.7.2.3 and 2.95.2): A large number of warnings appear, including the following: /usr/include/sys/resource.h: In function `getrlimit': /usr/include/sys/resource.h:168: warning: implicit declaration of function `__getrlimit64' /usr/include/sys/resource.h: In function `setrlimit': /usr/include/sys/resource.h:170: warning: implicit declaration of function `__setrlimit64' This would appear to be a problem with large file support, header files and gcc. gcc may or may not give up at this point. If it fails, you might be able to improve matters by adding -D__STDC_EXT__=1 to the BIGFILES variable in the Makefile (ie, change its definition to BIGFILES=-D_FILE_OFFSET_BITS=64 -D__STDC_EXT__=1 Even if gcc does produce a binary which appears to work (ie passes its self-tests), you might want to test it to see if it works properly on large files. * HP/UX 10.20 and 11.00, using HP's cc compiler. No specific problems for this combination, except that you'll need to specify the -Ae flag, and zap the gcc-specific stuff -Wall -Winline -O2 -fomit-frame-pointer -fno-strength-reduce. You should retain -D_FILE_OFFSET_BITS=64 in order to get large file support -- which is reported to work ok for this HP/UX + cc combination. * SunOS 4.1.X. Amazingly, there are still people out there using this venerable old banger. I shouldn't be too rude -- I started life on SunOS, and it was a pretty darn good OS, way back then. Anyway: SunOS doesn't seem to have strerror(), so you'll have to use perror(), perhaps by doing adding this (warning: UNTESTED CODE): char* strerror ( int errnum ) { if (errnum < 0 || errnum >= sys_nerr) return "Unknown error"; else return sys_errlist[errnum]; } Or you could comment out the relevant calls to strerror; they're not mission-critical. Or you could upgrade to Solaris. Ha ha ha! (what?? you think I've got Bad Attitude?) * Making a shared library on Solaris. (Not really a compilation problem, but many people ask ...) Firstly, if you have Solaris 8, either you have libbz2.so already on your system, or you can install it from the Solaris CD. Secondly, be aware that there are potential naming conflicts between the .so file supplied with Solaris 8, and the .so file which Makefile-libbz2_so will make. Makefile-libbz2_so creates a .so which has the names which I intend to be "official" as of version 1.0.0 and onwards. Unfortunately, the .so in Solaris 8 appeared before I decided on the final names, so the two libraries are incompatible. We have since communicated and I hope that the problems will have been solved in the next version of Solaris, whenever that might appear. All that said: you might be able to get somewhere by finding the line in Makefile-libbz2_so which says $(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.2 $(OBJS) and replacing with $(CC) -G -shared -o libbz2.so.1.0.2 -h libbz2.so.1.0 $(OBJS) If gcc objects to the combination -fpic -fPIC, get rid of the second one, leaving just "-fpic". That's the end of the currently known compilation problems. --- NEW FILE: Y2K_INFO --- Y2K status of bzip2 and libbzip2, versions 0.1, 0.9.0 and 0.9.5 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Informally speaking: bzip2 is a compression program built on top of libbzip2, a library which does the real work of compression and decompression. As far as I am aware, libbzip2 does not have any date-related code at all. bzip2 itself copies dates from source to destination files when compressing or decompressing, using the 'stat' and 'utime' UNIX system calls. It doesn't examine, manipulate or store the dates in any way. So as far as I can see, there shouldn't be any problem with bzip2 providing 'stat' and 'utime' work correctly on your system. On non-unix platforms (those for which BZ_UNIX in bzip2.c is not set to 1), bzip2 doesn't even do the date copying. Overall, informally speaking, I don't think bzip2 or libbzip2 have a Y2K problem. Formally speaking: I am not prepared to offer you any assurance whatsoever regarding Y2K issues in my software. You alone assume the entire risk of using the software. The disclaimer of liability in the LICENSE file in the bzip2 source distribution continues to apply on this issue as with every other issue pertaining to the software. Julian Seward Cambridge, UK 25 August 1999 --- NEW FILE: blocksort.c --- /*-------------------------------------------------------------*/ /*--- Block sorting machinery ---*/ /*--- blocksort.c ---*/ /*-------------------------------------------------------------*/ /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. [...1102 lines suppressed...] if (budget < 0) { if (verb >= 2) VPrintf0 ( " too repetitive; using fallback" " sorting algorithm\n" ); fallbackSort ( s->arr1, s->arr2, ftab, nblock, verb ); } } s->origPtr = -1; for (i = 0; i < s->nblock; i++) if (ptr[i] == 0) { s->origPtr = i; break; }; AssertH( s->origPtr != -1, 1003 ); } /*-------------------------------------------------------------*/ /*--- end blocksort.c ---*/ /*-------------------------------------------------------------*/ --- NEW FILE: bzdiff --- #!/bin/sh # sh is buggy on RS/6000 AIX 3.2. Replace above line with #!/bin/ksh # Bzcmp/diff wrapped for bzip2, # adapted from zdiff by Philippe Troin for Debian GNU/Linux. # Bzcmp and bzdiff are used to invoke the cmp or the diff pro- # gram on compressed files. All options specified are passed # directly to cmp or diff. If only 1 file is specified, then # the files compared are file1 and an uncompressed file1.gz. # If two files are specified, then they are uncompressed (if # necessary) and fed to cmp or diff. The exit status from cmp # or diff is preserved. PATH="/usr/bin:$PATH"; export PATH prog=`echo $0 | sed 's|.*/||'` case "$prog" in *cmp) comp=${CMP-cmp} ;; *) comp=${DIFF-diff} ;; esac OPTIONS= FILES= for ARG do case "$ARG" in -*) OPTIONS="$OPTIONS $ARG";; *) if test -f "$ARG"; then FILES="$FILES $ARG" else echo "${prog}: $ARG not found or not a regular file" exit 1 fi ;; esac done if test -z "$FILES"; then echo "Usage: $prog [${comp}_options] file [file]" exit 1 fi tmp=`tempfile -d /tmp -p bz` || { echo 'cannot create a temporary file' >&2 exit 1 } set $FILES if test $# -eq 1; then FILE=`echo "$1" | sed 's/.bz2$//'` bzip2 -cd "$FILE.bz2" | $comp $OPTIONS - "$FILE" STAT="$?" elif test $# -eq 2; then case "$1" in *.bz2) case "$2" in *.bz2) F=`echo "$2" | sed 's|.*/||;s|.bz2$||'` bzip2 -cdfq "$2" > $tmp bzip2 -cdfq "$1" | $comp $OPTIONS - $tmp STAT="$?" /bin/rm -f $tmp;; *) bzip2 -cdfq "$1" | $comp $OPTIONS - "$2" STAT="$?";; esac;; *) case "$2" in *.bz2) bzip2 -cdfq "$2" | $comp $OPTIONS "$1" - STAT="$?";; *) $comp $OPTIONS "$1" "$2" STAT="$?";; esac;; esac exit "$STAT" else echo "Usage: $prog [${comp}_options] file [file]" exit 1 fi --- NEW FILE: bzdiff.1 --- \"Shamelessly copied from zmore.1 by Philippe Troin \"for Debian GNU/Linux .TH BZDIFF 1 .SH NAME bzcmp, bzdiff \- compare bzip2 compressed files .SH SYNOPSIS .B bzcmp [ cmp_options ] file1 [ file2 ] .br .B bzdiff [ diff_options ] file1 [ file2 ] .SH DESCRIPTION .I Bzcmp and .I bzdiff are used to invoke the .I cmp or the .I diff program on bzip2 compressed files. All options specified are passed directly to .I cmp or .IR diff "." If only 1 file is specified, then the files compared are .I file1 and an uncompressed .IR file1 ".bz2." If two files are specified, then they are uncompressed if necessary and fed to .I cmp or .IR diff "." The exit status from .I cmp or .I diff is preserved. .SH "SEE ALSO" cmp(1), diff(1), bzmore(1), bzless(1), bzgrep(1), bzip2(1) .SH BUGS Messages from the .I cmp or .I diff programs refer to temporary filenames instead of those specified. --- NEW FILE: bzgrep --- #!/bin/sh # Bzgrep wrapped for bzip2, # adapted from zgrep by Philippe Troin for Debian GNU/Linux. ## zgrep notice: ## zgrep -- a wrapper around a grep program that decompresses files as needed ## Adapted from a version sent by Charles Levert PATH="/usr/bin:$PATH"; export PATH prog=`echo $0 | sed 's|.*/||'` case "$prog" in *egrep) grep=${EGREP-egrep} ;; *fgrep) grep=${FGREP-fgrep} ;; *) grep=${GREP-grep} ;; esac pat="" while test $# -ne 0; do case "$1" in -e | -f) opt="$opt $1"; shift; pat="$1" if test "$grep" = grep; then # grep is buggy with -e on SVR4 grep=egrep fi;; -A | -B) opt="$opt $1 $2"; shift;; -*) opt="$opt $1";; *) if test -z "$pat"; then pat="$1" else break; fi;; esac shift done if test -z "$pat"; then echo "grep through bzip2 files" echo "usage: $prog [grep_options] pattern [files]" exit 1 fi list=0 silent=0 op=`echo "$opt" | sed -e 's/ //g' -e 's/-//g'` case "$op" in *l*) list=1 esac case "$op" in *h*) silent=1 esac if test $# -eq 0; then bzip2 -cdfq | $grep $opt "$pat" exit $? fi res=0 for i do if test -f "$i"; then :; else if test -f "$i.bz2"; then i="$i.bz2"; fi; fi if test $list -eq 1; then bzip2 -cdfq "$i" | $grep $opt "$pat" 2>&1 > /dev/null && echo $i r=$? elif test $# -eq 1 -o $silent -eq 1; then bzip2 -cdfq "$i" | $grep $opt "$pat" r=$? else bzip2 -cdfq "$i" | $grep $opt "$pat" | sed "s|^|${i}:|" r=$? fi test "$r" -ne 0 && res="$r" done exit $res --- NEW FILE: bzgrep.1 --- \"Shamelessly copied from zmore.1 by Philippe Troin \"for Debian GNU/Linux .TH BZGREP 1 .SH NAME bzgrep, bzfgrep, bzegrep \- search possibly bzip2 compressed files for a regular expression .SH SYNOPSIS .B bzgrep [ grep_options ] .BI [\ -e\ ] " pattern" .IR filename ".\|.\|." .br .B bzegrep [ egrep_options ] .BI [\ -e\ ] " pattern" .IR filename ".\|.\|." .br .B bzfgrep [ fgrep_options ] .BI [\ -e\ ] " pattern" .IR filename ".\|.\|." .SH DESCRIPTION .IR Bzgrep is used to invoke the .I grep on bzip2-compressed files. All options specified are passed directly to .I grep. If no file is specified, then the standard input is decompressed if necessary and fed to grep. Otherwise the given files are uncompressed if necessary and fed to .I grep. .PP If .I bzgrep is invoked as .I bzegrep or .I bzfgrep then .I egrep or .I fgrep is used instead of .I grep. If the GREP environment variable is set, .I bzgrep uses it as the .I grep program to be invoked. For example: for sh: GREP=fgrep bzgrep string files for csh: (setenv GREP fgrep; bzgrep string files) .SH AUTHOR Charles Levert (charles at comm.polymtl.ca). Adapted to bzip2 by Philippe Troin for Debian GNU/Linux. .SH "SEE ALSO" grep(1), egrep(1), fgrep(1), bzdiff(1), bzmore(1), bzless(1), bzip2(1) --- NEW FILE: bzip2.1 --- .PU .TH bzip2 1 .SH NAME bzip2, bunzip2 \- a block-sorting file compressor, v1.0.2 .br bzcat \- decompresses files to stdout .br bzip2recover \- recovers data from damaged bzip2 files .SH SYNOPSIS .ll +8 .B bzip2 .RB [ " \-cdfkqstvzVL123456789 " ] [ .I "filenames \&..." ] .ll -8 .br .B bunzip2 .RB [ " \-fkvsVL " ] [ .I "filenames \&..." ] .br .B bzcat .RB [ " \-s " ] [ .I "filenames \&..." ] .br .B bzip2recover .I "filename" .SH DESCRIPTION .I bzip2 compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than that achieved by more conventional LZ77/LZ78-based compressors, and approaches the performance of the PPM family of statistical compressors. The command-line options are deliberately very similar to those of .I GNU gzip, but they are not identical. .I bzip2 expects a list of file names to accompany the command-line flags. Each file is replaced by a compressed version of itself, with the name "original_name.bz2". Each compressed file has the same modification date, permissions, and, when possible, ownership as the corresponding original, so that these properties can be correctly restored at decompression time. File name handling is naive in the sense that there is no mechanism for preserving original file names, permissions, ownerships or dates in filesystems which lack these concepts, or have serious file name length restrictions, such as MS-DOS. .I bzip2 and .I bunzip2 will by default not overwrite existing files. If you want this to happen, specify the \-f flag. If no file names are specified, .I bzip2 compresses from standard input to standard output. In this case, .I bzip2 will decline to write compressed output to a terminal, as this would be entirely incomprehensible and therefore pointless. .I bunzip2 (or .I bzip2 \-d) decompresses all specified files. Files which were not created by .I bzip2 will be detected and ignored, and a warning issued. .I bzip2 attempts to guess the filename for the decompressed file from that of the compressed file as follows: filename.bz2 becomes filename filename.bz becomes filename filename.tbz2 becomes filename.tar filename.tbz becomes filename.tar anyothername becomes anyothername.out If the file does not end in one of the recognised endings, .I .bz2, .I .bz, .I .tbz2 or .I .tbz, .I bzip2 complains that it cannot guess the name of the original file, and uses the original name with .I .out appended. As with compression, supplying no filenames causes decompression from standard input to standard output. .I bunzip2 will correctly decompress a file which is the concatenation of two or more compressed files. The result is the concatenation of the corresponding uncompressed files. Integrity testing (\-t) of concatenated compressed files is also supported. You can also compress or decompress files to the standard output by giving the \-c flag. Multiple files may be compressed and decompressed like this. The resulting outputs are fed sequentially to stdout. Compression of multiple files in this manner generates a stream containing multiple compressed file representations. Such a stream can be decompressed correctly only by .I bzip2 version 0.9.0 or later. Earlier versions of .I bzip2 will stop after decompressing the first file in the stream. .I bzcat (or .I bzip2 -dc) decompresses all specified files to the standard output. .I bzip2 will read arguments from the environment variables .I BZIP2 and .I BZIP, in that order, and will process them before any arguments read from the command line. This gives a convenient way to supply default arguments. Compression is always performed, even if the compressed file is slightly larger than the original. Files of less than about one hundred bytes tend to get larger, since the compression mechanism has a constant overhead in the region of 50 bytes. Random data (including the output of most file compressors) is coded at about 8.05 bits per byte, giving an expansion of around 0.5%. As a self-check for your protection, .I bzip2 uses 32-bit CRCs to make sure that the decompressed version of a file is identical to the original. This guards against corruption of the compressed data, and against undetected bugs in .I bzip2 (hopefully very unlikely). The chances of data corruption going undetected is microscopic, about one chance in four billion for each file processed. Be aware, though, that the check occurs upon decompression, so it can only tell you that something is wrong. It can't help you recover the original uncompressed data. You can use .I bzip2recover to try to recover data from damaged files. Return values: 0 for a normal exit, 1 for environmental problems (file not found, invalid flags, I/O errors, &c), 2 to indicate a corrupt compressed file, 3 for an internal consistency error (eg, bug) which caused .I bzip2 to panic. .SH OPTIONS .TP .B \-c --stdout Compress or decompress to standard output. .TP .B \-d --decompress Force decompression. .I bzip2, .I bunzip2 and .I bzcat are really the same program, and the decision about what actions to take is done on the basis of which name is used. This flag overrides that mechanism, and forces .I bzip2 to decompress. .TP .B \-z --compress The complement to \-d: forces compression, regardless of the invocation name. .TP .B \-t --test Check integrity of the specified file(s), but don't decompress them. This really performs a trial decompression and throws away the result. .TP .B \-f --force Force overwrite of output files. Normally, .I bzip2 will not overwrite existing output files. Also forces .I bzip2 to break hard links to files, which it otherwise wouldn't do. bzip2 normally declines to decompress files which don't have the correct magic header bytes. If forced (-f), however, it will pass such files through unmodified. This is how GNU gzip behaves. .TP .B \-k --keep Keep (don't delete) input files during compression or decompression. .TP .B \-s --small Reduce memory usage, for compression, decompression and testing. Files are decompressed and tested using a modified algorithm which only requires 2.5 bytes per block byte. This means any file can be decompressed in 2300k of memory, albeit at about half the normal speed. During compression, \-s selects a block size of 200k, which limits memory use to around the same figure, at the expense of your compression ratio. In short, if your machine is low on memory (8 megabytes or less), use \-s for everything. See MEMORY MANAGEMENT below. .TP .B \-q --quiet Suppress non-essential warning messages. Messages pertaining to I/O errors and other critical events will not be suppressed. .TP .B \-v --verbose Verbose mode -- show the compression ratio for each file processed. Further \-v's increase the verbosity level, spewing out lots of information which is primarily of interest for diagnostic purposes. .TP .B \-L --license -V --version Display the software version, license terms and conditions. .TP .B \-1 (or \-\-fast) to \-9 (or \-\-best) Set the block size to 100 k, 200 k .. 900 k when compressing. Has no effect when decompressing. See MEMORY MANAGEMENT below. The \-\-fast and \-\-best aliases are primarily for GNU gzip compatibility. In particular, \-\-fast doesn't make things significantly faster. And \-\-best merely selects the default behaviour. .TP .B \-- Treats all subsequent arguments as file names, even if they start with a dash. This is so you can handle files with names beginning with a dash, for example: bzip2 \-- \-myfilename. .TP .B \--repetitive-fast --repetitive-best These flags are redundant in versions 0.9.5 and above. They provided some coarse control over the behaviour of the sorting algorithm in earlier versions, which was sometimes useful. 0.9.5 and above have an improved algorithm which renders these flags irrelevant. .SH MEMORY MANAGEMENT .I bzip2 compresses large files in blocks. The block size affects both the compression ratio achieved, and the amount of memory needed for compression and decompression. The flags \-1 through \-9 specify the block size to be 100,000 bytes through 900,000 bytes (the default) respectively. At decompression time, the block size used for compression is read from the header of the compressed file, and .I bunzip2 then allocates itself just enough memory to decompress the file. Since block sizes are stored in compressed files, it follows that the flags \-1 to \-9 are irrelevant to and so ignored during decompression. Compression and decompression requirements, in bytes, can be estimated as: Compression: 400k + ( 8 x block size ) Decompression: 100k + ( 4 x block size ), or 100k + ( 2.5 x block size ) Larger block sizes give rapidly diminishing marginal returns. Most of the compression comes from the first two or three hundred k of block size, a fact worth bearing in mind when using .I bzip2 on small machines. It is also important to appreciate that the decompression memory requirement is set at compression time by the choice of block size. For files compressed with the default 900k block size, .I bunzip2 will require about 3700 kbytes to decompress. To support decompression of any file on a 4 megabyte machine, .I bunzip2 has an option to decompress using approximately half this amount of memory, about 2300 kbytes. Decompression speed is also halved, so you should use this option only where necessary. The relevant flag is -s. In general, try and use the largest block size memory constraints allow, since that maximises the compression achieved. Compression and decompression speed are virtually unaffected by block size. Another significant point applies to files which fit in a single block -- that means most files you'd encounter using a large block size. The amount of real memory touched is proportional to the size of the file, since the file is smaller than a block. For example, compressing a file 20,000 bytes long with the flag -9 will cause the compressor to allocate around 7600k of memory, but only touch 400k + 20000 * 8 = 560 kbytes of it. Similarly, the decompressor will allocate 3700k but only touch 100k + 20000 * 4 = 180 kbytes. Here is a table which summarises the maximum memory usage for different block sizes. Also recorded is the total compressed size for 14 files of the Calgary Text Compression Corpus totalling 3,141,622 bytes. This column gives some feel for how compression varies with block size. These figures tend to understate the advantage of larger block sizes for larger files, since the Corpus is dominated by smaller files. Compress Decompress Decompress Corpus Flag usage usage -s usage Size -1 1200k 500k 350k 914704 -2 2000k 900k 600k 877703 -3 2800k 1300k 850k 860338 -4 3600k 1700k 1100k 846899 -5 4400k 2100k 1350k 845160 -6 5200k 2500k 1600k 838626 -7 6100k 2900k 1850k 834096 -8 6800k 3300k 2100k 828642 -9 7600k 3700k 2350k 828642 .SH RECOVERING DATA FROM DAMAGED FILES .I bzip2 compresses files in blocks, usually 900kbytes long. Each block is handled independently. If a media or transmission error causes a multi-block .bz2 file to become damaged, it may be possible to recover data from the undamaged blocks in the file. The compressed representation of each block is delimited by a 48-bit pattern, which makes it possible to find the block boundaries with reasonable certainty. Each block also carries its own 32-bit CRC, so damaged blocks can be distinguished from undamaged ones. .I bzip2recover is a simple program whose purpose is to search for blocks in .bz2 files, and write each block out into its own .bz2 file. You can then use .I bzip2 \-t to test the integrity of the resulting files, and decompress those which are undamaged. .I bzip2recover takes a single argument, the name of the damaged file, and writes a number of files "rec00001file.bz2", "rec00002file.bz2", etc, containing the extracted blocks. The output filenames are designed so that the use of wildcards in subsequent processing -- for example, "bzip2 -dc rec*file.bz2 > recovered_data" -- processes the files in the correct order. .I bzip2recover should be of most use dealing with large .bz2 files, as these will contain many blocks. It is clearly futile to use it on damaged single-block files, since a damaged block cannot be recovered. If you wish to minimise any potential data loss through media or transmission errors, you might consider compressing with a smaller block size. .SH PERFORMANCE NOTES The sorting phase of compression gathers together similar strings in the file. Because of this, files containing very long runs of repeated symbols, like "aabaabaabaab ..." (repeated several hundred times) may compress more slowly than normal. Versions 0.9.5 and above fare much better than previous versions in this respect. The ratio between worst-case and average-case compression time is in the region of 10:1. For previous versions, this figure was more like 100:1. You can use the \-vvvv option to monitor progress in great detail, if you want. Decompression speed is unaffected by these phenomena. .I bzip2 usually allocates several megabytes of memory to operate in, and then charges all over it in a fairly random fashion. This means that performance, both for compressing and decompressing, is largely determined by the speed at which your machine can service cache misses. Because of this, small changes to the code to reduce the miss rate have been observed to give disproportionately large performance improvements. I imagine .I bzip2 will perform best on machines with very large caches. .SH CAVEATS I/O error messages are not as helpful as they could be. .I bzip2 tries hard to detect I/O errors and exit cleanly, but the details of what the problem is sometimes seem rather misleading. This manual page pertains to version 1.0.2 of .I bzip2. Compressed data created by this version is entirely forwards and backwards compatible with the previous public releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0 and 1.0.1, but with the following exception: 0.9.0 and above can correctly decompress multiple concatenated compressed files. 0.1pl2 cannot do this; it will stop after decompressing just the first file in the stream. .I bzip2recover versions prior to this one, 1.0.2, used 32-bit integers to represent bit positions in compressed files, so it could not handle compressed files more than 512 megabytes long. Version 1.0.2 and above uses 64-bit ints on some platforms which support them (GNU supported targets, and Windows). To establish whether or not bzip2recover was built with such a limitation, run it without arguments. In any event you can build yourself an unlimited version if you can recompile it with MaybeUInt64 set to be an unsigned 64-bit integer. .SH AUTHOR Julian Seward, jseward at acm.org. http://sources.redhat.com/bzip2 The ideas embodied in .I bzip2 are due to (at least) the following people: Michael Burrows and David Wheeler (for the block sorting transformation), David Wheeler (again, for the Huffman coder), Peter Fenwick (for the structured coding model in the original .I bzip, and many refinements), and Alistair Moffat, Radford Neal and Ian Witten (for the arithmetic coder in the original .I bzip). I am much indebted for their help, support and advice. See the manual in the source distribution for pointers to sources of documentation. Christian von Roques encouraged me to look for faster sorting algorithms, so as to speed up compression. Bela Lubkin encouraged me to improve the worst-case compression performance. The bz* scripts are derived from those of GNU gzip. Many people sent patches, helped with portability problems, lent machines, gave advice and were generally helpful. --- NEW FILE: bzip2.1.preformatted --- bzip2(1) bzip2(1) NNAAMMEE bzip2, bunzip2 - a block-sorting file compressor, v1.0.2 bzcat - decompresses files to stdout bzip2recover - recovers data from damaged bzip2 files SSYYNNOOPPSSIISS bbzziipp22 [ --ccddffkkqqssttvvzzVVLL112233445566778899 ] [ _f_i_l_e_n_a_m_e_s _._._. ] bbuunnzziipp22 [ --ffkkvvssVVLL ] [ _f_i_l_e_n_a_m_e_s _._._. ] bbzzccaatt [ --ss ] [ _f_i_l_e_n_a_m_e_s _._._. ] bbzziipp22rreeccoovveerr _f_i_l_e_n_a_m_e DDEESSCCRRIIPPTTIIOONN _b_z_i_p_2 compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than that achieved by more conventional LZ77/LZ78-based compressors, and approaches the performance of the PPM family of sta? tistical compressors. The command-line options are deliberately very similar to those of _G_N_U _g_z_i_p_, but they are not identical. _b_z_i_p_2 expects a list of file names to accompany the com? mand-line flags. Each file is replaced by a compressed version of itself, with the name "original_name.bz2". Each compressed file has the same modification date, per? missions, and, when possible, ownership as the correspond? ing original, so that these properties can be correctly restored at decompression time. File name handling is naive in the sense that there is no mechanism for preserv? ing original file names, permissions, ownerships or dates in filesystems which lack these concepts, or have serious file name length restrictions, such as MS-DOS. _b_z_i_p_2 and _b_u_n_z_i_p_2 will by default not overwrite existing files. If you want this to happen, specify the -f flag. If no file names are specified, _b_z_i_p_2 compresses from standard input to standard output. In this case, _b_z_i_p_2 will decline to write compressed output to a terminal, as this would be entirely incomprehensible and therefore pointless. _b_u_n_z_i_p_2 (or _b_z_i_p_2 _-_d_) decompresses all specified files. Files which were not created by _b_z_i_p_2 will be detected and ignored, and a warning issued. _b_z_i_p_2 attempts to guess the filename for the decompressed file from that of the compressed file as follows: filename.bz2 becomes filename filename.bz becomes filename filename.tbz2 becomes filename.tar filename.tbz becomes filename.tar anyothername becomes anyothername.out If the file does not end in one of the recognised endings, _._b_z_2_, _._b_z_, _._t_b_z_2 or _._t_b_z_, _b_z_i_p_2 complains that it cannot guess the name of the original file, and uses the original name with _._o_u_t appended. As with compression, supplying no filenames causes decom? pression from standard input to standard output. _b_u_n_z_i_p_2 will correctly decompress a file which is the con? catenation of two or more compressed files. The result is the concatenation of the corresponding uncompressed files. Integrity testing (-t) of concatenated compressed files is also supported. You can also compress or decompress files to the standard output by giving the -c flag. Multiple files may be com? pressed and decompressed like this. The resulting outputs are fed sequentially to stdout. Compression of multiple files in this manner generates a stream containing multi? ple compressed file representations. Such a stream can be decompressed correctly only by _b_z_i_p_2 version 0.9.0 or later. Earlier versions of _b_z_i_p_2 will stop after decom? pressing the first file in the stream. _b_z_c_a_t (or _b_z_i_p_2 _-_d_c_) decompresses all specified files to the standard output. _b_z_i_p_2 will read arguments from the environment variables _B_Z_I_P_2 and _B_Z_I_P_, in that order, and will process them before any arguments read from the command line. This gives a convenient way to supply default arguments. Compression is always performed, even if the compressed file is slightly larger than the original. Files of less than about one hundred bytes tend to get larger, since the compression mechanism has a constant overhead in the region of 50 bytes. Random data (including the output of most file compressors) is coded at about 8.05 bits per byte, giving an expansion of around 0.5%. As a self-check for your protection, _b_z_i_p_2 uses 32-bit CRCs to make sure that the decompressed version of a file is identical to the original. This guards against corrup? tion of the compressed data, and against undetected bugs in _b_z_i_p_2 (hopefully very unlikely). The chances of data corruption going undetected is microscopic, about one chance in four billion for each file processed. Be aware, though, that the check occurs upon decompression, so it can only tell you that something is wrong. It can't help you recover the original uncompressed data. You can use _b_z_i_p_2_r_e_c_o_v_e_r to try to recover data from damaged files. Return values: 0 for a normal exit, 1 for environmental problems (file not found, invalid flags, I/O errors, &c), 2 to indicate a corrupt compressed file, 3 for an internal consistency error (eg, bug) which caused _b_z_i_p_2 to panic. OOPPTTIIOONNSS --cc ----ssttddoouutt Compress or decompress to standard output. --dd ----ddeeccoommpprreessss Force decompression. _b_z_i_p_2_, _b_u_n_z_i_p_2 and _b_z_c_a_t are really the same program, and the decision about what actions to take is done on the basis of which name is used. This flag overrides that mechanism, and forces _b_z_i_p_2 to decompress. --zz ----ccoommpprreessss The complement to -d: forces compression, regardless of the invocation name. --tt ----tteesstt Check integrity of the specified file(s), but don't decompress them. This really performs a trial decompression and throws away the result. --ff ----ffoorrccee Force overwrite of output files. Normally, _b_z_i_p_2 will not overwrite existing output files. Also forces _b_z_i_p_2 to break hard links to files, which it otherwise wouldn't do. bzip2 normally declines to decompress files which don't have the correct magic header bytes. If forced (-f), however, it will pass such files through unmodified. This is how GNU gzip behaves. --kk ----kkeeeepp Keep (don't delete) input files during compression or decompression. --ss ----ssmmaallll Reduce memory usage, for compression, decompression and testing. Files are decompressed and tested using a modified algorithm which only requires 2.5 bytes per block byte. This means any file can be decompressed in 2300k of memory, albeit at about half the normal speed. During compression, -s selects a block size of 200k, which limits memory use to around the same figure, at the expense of your compression ratio. In short, if your machine is low on memory (8 megabytes or less), use -s for everything. See MEMORY MANAGEMENT below. --qq ----qquuiieett Suppress non-essential warning messages. Messages pertaining to I/O errors and other critical events will not be suppressed. --vv ----vveerrbboossee Verbose mode -- show the compression ratio for each file processed. Further -v's increase the ver? bosity level, spewing out lots of information which is primarily of interest for diagnostic purposes. --LL ----lliicceennssee --VV ----vveerrssiioonn Display the software version, license terms and conditions. --11 ((oorr ----ffaasstt)) ttoo --99 ((oorr ----bbeesstt)) Set the block size to 100 k, 200 k .. 900 k when compressing. Has no effect when decompressing. See MEMORY MANAGEMENT below. The --fast and --best aliases are primarily for GNU gzip compatibility. In particular, --fast doesn't make things signifi? cantly faster. And --best merely selects the default behaviour. ---- Treats all subsequent arguments as file names, even if they start with a dash. This is so you can han? dle files with names beginning with a dash, for example: bzip2 -- -myfilename. ----rreeppeettiittiivvee--ffaasstt ----rreeppeettiittiivvee--bbeesstt These flags are redundant in versions 0.9.5 and above. They provided some coarse control over the behaviour of the sorting algorithm in earlier ver? sions, which was sometimes useful. 0.9.5 and above have an improved algorithm which renders these flags irrelevant. MMEEMMOORRYY MMAANNAAGGEEMMEENNTT _b_z_i_p_2 compresses large files in blocks. The block size affects both the compression ratio achieved, and the amount of memory needed for compression and decompression. The flags -1 through -9 specify the block size to be 100,000 bytes through 900,000 bytes (the default) respec? tively. At decompression time, the block size used for compression is read from the header of the compressed file, and _b_u_n_z_i_p_2 then allocates itself just enough memory to decompress the file. Since block sizes are stored in compressed files, it follows that the flags -1 to -9 are irrelevant to and so ignored during decompression. Compression and decompression requirements, in bytes, can be estimated as: Compression: 400k + ( 8 x block size ) Decompression: 100k + ( 4 x block size ), or 100k + ( 2.5 x block size ) Larger block sizes give rapidly diminishing marginal returns. Most of the compression comes from the first two or three hundred k of block size, a fact worth bearing in mind when using _b_z_i_p_2 on small machines. It is also important to appreciate that the decompression memory requirement is set at compression time by the choice of block size. For files compressed with the default 900k block size, _b_u_n_z_i_p_2 will require about 3700 kbytes to decompress. To support decompression of any file on a 4 megabyte machine, _b_u_n_z_i_p_2 has an option to decompress using approximately half this amount of memory, about 2300 kbytes. Decompres? sion speed is also halved, so you should use this option only where necessary. The relevant flag is -s. In general, try and use the largest block size memory con? straints allow, since that maximises the compression achieved. Compression and decompression speed are virtu? ally unaffected by block size. Another significant point applies to files which fit in a single block -- that means most files you'd encounter using a large block size. The amount of real memory touched is proportional to the size of the file, since the file is smaller than a block. For example, compressing a file 20,000 bytes long with the flag -9 will cause the compressor to allocate around 7600k of memory, but only touch 400k + 20000 * 8 = 560 kbytes of it. Similarly, the decompressor will allocate 3700k but only touch 100k + 20000 * 4 = 180 kbytes. Here is a table which summarises the maximum memory usage for different block sizes. Also recorded is the total compressed size for 14 files of the Calgary Text Compres? sion Corpus totalling 3,141,622 bytes. This column gives some feel for how compression varies with block size. These figures tend to understate the advantage of larger block sizes for larger files, since the Corpus is domi? nated by smaller files. Compress Decompress Decompress Corpus Flag usage usage -s usage Size -1 1200k 500k 350k 914704 -2 2000k 900k 600k 877703 -3 2800k 1300k 850k 860338 -4 3600k 1700k 1100k 846899 -5 4400k 2100k 1350k 845160 -6 5200k 2500k 1600k 838626 -7 6100k 2900k 1850k 834096 -8 6800k 3300k 2100k 828642 -9 7600k 3700k 2350k 828642 RREECCOOVVEERRIINNGG DDAATTAA FFRROOMM DDAAMMAAGGEEDD FFIILLEESS _b_z_i_p_2 compresses files in blocks, usually 900kbytes long. Each block is handled independently. If a media or trans? mission error causes a multi-block .bz2 file to become damaged, it may be possible to recover data from the undamaged blocks in the file. The compressed representation of each block is delimited by a 48-bit pattern, which makes it possible to find the block boundaries with reasonable certainty. Each block also carries its own 32-bit CRC, so damaged blocks can be distinguished from undamaged ones. _b_z_i_p_2_r_e_c_o_v_e_r is a simple program whose purpose is to search for blocks in .bz2 files, and write each block out into its own .bz2 file. You can then use _b_z_i_p_2 -t to test the integrity of the resulting files, and decompress those which are undamaged. _b_z_i_p_2_r_e_c_o_v_e_r takes a single argument, the name of the dam? aged file, and writes a number of files "rec00001file.bz2", "rec00002file.bz2", etc, containing the extracted blocks. The output filenames are designed so that the use of wildcards in subsequent pro? cessing -- for example, "bzip2 -dc rec*file.bz2 > recov? ered_data" -- processes the files in the correct order. _b_z_i_p_2_r_e_c_o_v_e_r should be of most use dealing with large .bz2 files, as these will contain many blocks. It is clearly futile to use it on damaged single-block files, since a damaged block cannot be recovered. If you wish to min? imise any potential data loss through media or transmis? sion errors, you might consider compressing with a smaller block size. PPEERRFFOORRMMAANNCCEE NNOOTTEESS The sorting phase of compression gathers together similar strings in the file. Because of this, files containing very long runs of repeated symbols, like "aabaabaabaab ..." (repeated several hundred times) may compress more slowly than normal. Versions 0.9.5 and above fare much better than previous versions in this respect. The ratio between worst-case and average-case compression time is in the region of 10:1. For previous versions, this figure was more like 100:1. You can use the -vvvv option to mon? itor progress in great detail, if you want. Decompression speed is unaffected by these phenomena. _b_z_i_p_2 usually allocates several megabytes of memory to operate in, and then charges all over it in a fairly ran? dom fashion. This means that performance, both for com? pressing and decompressing, is largely determined by the speed at which your machine can service cache misses. Because of this, small changes to the code to reduce the miss rate have been observed to give disproportionately large performance improvements. I imagine _b_z_i_p_2 will per? form best on machines with very large caches. CCAAVVEEAATTSS I/O error messages are not as helpful as they could be. _b_z_i_p_2 tries hard to detect I/O errors and exit cleanly, but the details of what the problem is sometimes seem rather misleading. This manual page pertains to version 1.0.2 of _b_z_i_p_2_. Com? pressed data created by this version is entirely forwards and backwards compatible with the previous public releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0 and 1.0.1, but with the following exception: 0.9.0 and above can cor? rectly decompress multiple concatenated compressed files. 0.1pl2 cannot do this; it will stop after decompressing just the first file in the stream. _b_z_i_p_2_r_e_c_o_v_e_r versions prior to this one, 1.0.2, used 32-bit integers to represent bit positions in compressed files, so it could not handle compressed files more than 512 megabytes long. Version 1.0.2 and above uses 64-bit ints on some platforms which support them (GNU supported targets, and Windows). To establish whether or not bzip2recover was built with such a limitation, run it without arguments. In any event you can build yourself an unlimited version if you can recompile it with MaybeUInt64 set to be an unsigned 64-bit integer. AAUUTTHHOORR Julian Seward, jseward at acm.org. http://sources.redhat.com/bzip2 The ideas embodied in _b_z_i_p_2 are due to (at least) the fol? lowing people: Michael Burrows and David Wheeler (for the block sorting transformation), David Wheeler (again, for the Huffman coder), Peter Fenwick (for the structured cod? ing model in the original _b_z_i_p_, and many refinements), and Alistair Moffat, Radford Neal and Ian Witten (for the arithmetic coder in the original _b_z_i_p_)_. I am much indebted for their help, support and advice. See the man? ual in the source distribution for pointers to sources of documentation. Christian von Roques encouraged me to look for faster sorting algorithms, so as to speed up compres? sion. Bela Lubkin encouraged me to improve the worst-case compression performance. The bz* scripts are derived from those of GNU gzip. Many people sent patches, helped with portability problems, lent machines, gave advice and were generally helpful. bzip2(1) --- NEW FILE: bzip2.c --- /*-----------------------------------------------------------*/ /*--- A block-sorting, lossless compressor bzip2.c ---*/ /*-----------------------------------------------------------*/ /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must [...2064 lines suppressed...] } /* Free the argument list memory to mollify leak detectors (eg) Purify, Checker. Serves no other useful purpose. */ aa = argList; while (aa != NULL) { Cell* aa2 = aa->link; if (aa->name != NULL) free(aa->name); free(aa); aa = aa2; } return exitValue; } /*-----------------------------------------------------------*/ /*--- end bzip2.c ---*/ /*-----------------------------------------------------------*/ --- NEW FILE: bzip2.txt --- NAME bzip2, bunzip2 - a block-sorting file compressor, v1.0.2 bzcat - decompresses files to stdout bzip2recover - recovers data from damaged bzip2 files SYNOPSIS bzip2 [ -cdfkqstvzVL123456789 ] [ filenames ... ] bunzip2 [ -fkvsVL ] [ filenames ... ] bzcat [ -s ] [ filenames ... ] bzip2recover filename DESCRIPTION bzip2 compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than that achieved by more conventional LZ77/LZ78-based compressors, and approaches the performance of the PPM family of sta? tistical compressors. The command-line options are deliberately very similar to those of GNU gzip, but they are not identical. bzip2 expects a list of file names to accompany the com? mand-line flags. Each file is replaced by a compressed version of itself, with the name "original_name.bz2". Each compressed file has the same modification date, per? missions, and, when possible, ownership as the correspond? ing original, so that these properties can be correctly restored at decompression time. File name handling is naive in the sense that there is no mechanism for preserv? ing original file names, permissions, ownerships or dates in filesystems which lack these concepts, or have serious file name length restrictions, such as MS-DOS. bzip2 and bunzip2 will by default not overwrite existing files. If you want this to happen, specify the -f flag. If no file names are specified, bzip2 compresses from standard input to standard output. In this case, bzip2 will decline to write compressed output to a terminal, as this would be entirely incomprehensible and therefore pointless. bunzip2 (or bzip2 -d) decompresses all specified files. Files which were not created by bzip2 will be detected and ignored, and a warning issued. bzip2 attempts to guess the filename for the decompressed file from that of the compressed file as follows: filename.bz2 becomes filename filename.bz becomes filename filename.tbz2 becomes filename.tar filename.tbz becomes filename.tar anyothername becomes anyothername.out If the file does not end in one of the recognised endings, .bz2, .bz, .tbz2 or .tbz, bzip2 complains that it cannot guess the name of the original file, and uses the original name with .out appended. As with compression, supplying no filenames causes decom? pression from standard input to standard output. bunzip2 will correctly decompress a file which is the con? catenation of two or more compressed files. The result is the concatenation of the corresponding uncompressed files. Integrity testing (-t) of concatenated compressed files is also supported. You can also compress or decompress files to the standard output by giving the -c flag. Multiple files may be com? pressed and decompressed like this. The resulting outputs are fed sequentially to stdout. Compression of multiple files in this manner generates a stream containing multi? ple compressed file representations. Such a stream can be decompressed correctly only by bzip2 version 0.9.0 or later. Earlier versions of bzip2 will stop after decom? pressing the first file in the stream. bzcat (or bzip2 -dc) decompresses all specified files to the standard output. bzip2 will read arguments from the environment variables BZIP2 and BZIP, in that order, and will process them before any arguments read from the command line. This gives a convenient way to supply default arguments. Compression is always performed, even if the compressed file is slightly larger than the original. Files of less than about one hundred bytes tend to get larger, since the compression mechanism has a constant overhead in the region of 50 bytes. Random data (including the output of most file compressors) is coded at about 8.05 bits per byte, giving an expansion of around 0.5%. As a self-check for your protection, bzip2 uses 32-bit CRCs to make sure that the decompressed version of a file is identical to the original. This guards against corrup? tion of the compressed data, and against undetected bugs in bzip2 (hopefully very unlikely). The chances of data corruption going undetected is microscopic, about one chance in four billion for each file processed. Be aware, though, that the check occurs upon decompression, so it can only tell you that something is wrong. It can't help you recover the original uncompressed data. You can use bzip2recover to try to recover data from damaged files. Return values: 0 for a normal exit, 1 for environmental problems (file not found, invalid flags, I/O errors, &c), 2 to indicate a corrupt compressed file, 3 for an internal consistency error (eg, bug) which caused bzip2 to panic. OPTIONS -c --stdout Compress or decompress to standard output. -d --decompress Force decompression. bzip2, bunzip2 and bzcat are really the same program, and the decision about what actions to take is done on the basis of which name is used. This flag overrides that mechanism, and forces bzip2 to decompress. -z --compress The complement to -d: forces compression, regardless of the invocation name. -t --test Check integrity of the specified file(s), but don't decompress them. This really performs a trial decompression and throws away the result. -f --force Force overwrite of output files. Normally, bzip2 will not overwrite existing output files. Also forces bzip2 to break hard links to files, which it otherwise wouldn't do. bzip2 normally declines to decompress files which don't have the correct magic header bytes. If forced (-f), however, it will pass such files through unmodified. This is how GNU gzip behaves. -k --keep Keep (don't delete) input files during compression or decompression. -s --small Reduce memory usage, for compression, decompression and testing. Files are decompressed and tested using a modified algorithm which only requires 2.5 bytes per block byte. This means any file can be decompressed in 2300k of memory, albeit at about half the normal speed. During compression, -s selects a block size of 200k, which limits memory use to around the same figure, at the expense of your compression ratio. In short, if your machine is low on memory (8 megabytes or less), use -s for everything. See MEMORY MANAGEMENT below. -q --quiet Suppress non-essential warning messages. Messages pertaining to I/O errors and other critical events will not be suppressed. -v --verbose Verbose mode -- show the compression ratio for each file processed. Further -v's increase the ver? bosity level, spewing out lots of information which is primarily of interest for diagnostic purposes. -L --license -V --version Display the software version, license terms and conditions. -1 (or --fast) to -9 (or --best) Set the block size to 100 k, 200 k .. 900 k when compressing. Has no effect when decompressing. See MEMORY MANAGEMENT below. The --fast and --best aliases are primarily for GNU gzip compatibility. In particular, --fast doesn't make things signifi? cantly faster. And --best merely selects the default behaviour. -- Treats all subsequent arguments as file names, even if they start with a dash. This is so you can han? dle files with names beginning with a dash, for example: bzip2 -- -myfilename. --repetitive-fast --repetitive-best These flags are redundant in versions 0.9.5 and above. They provided some coarse control over the behaviour of the sorting algorithm in earlier ver? sions, which was sometimes useful. 0.9.5 and above have an improved algorithm which renders these flags irrelevant. MEMORY MANAGEMENT bzip2 compresses large files in blocks. The block size affects both the compression ratio achieved, and the amount of memory needed for compression and decompression. The flags -1 through -9 specify the block size to be 100,000 bytes through 900,000 bytes (the default) respec? tively. At decompression time, the block size used for compression is read from the header of the compressed file, and bunzip2 then allocates itself just enough memory to decompress the file. Since block sizes are stored in compressed files, it follows that the flags -1 to -9 are irrelevant to and so ignored during decompression. Compression and decompression requirements, in bytes, can be estimated as: Compression: 400k + ( 8 x block size ) Decompression: 100k + ( 4 x block size ), or 100k + ( 2.5 x block size ) Larger block sizes give rapidly diminishing marginal returns. Most of the compression comes from the first two or three hundred k of block size, a fact worth bearing in mind when using bzip2 on small machines. It is also important to appreciate that the decompression memory requirement is set at compression time by the choice of block size. For files compressed with the default 900k block size, bunzip2 will require about 3700 kbytes to decompress. To support decompression of any file on a 4 megabyte machine, bunzip2 has an option to decompress using approximately half this amount of memory, about 2300 kbytes. Decompres? sion speed is also halved, so you should use this option only where necessary. The relevant flag is -s. In general, try and use the largest block size memory con? straints allow, since that maximises the compression achieved. Compression and decompression speed are virtu? ally unaffected by block size. Another significant point applies to files which fit in a single block -- that means most files you'd encounter using a large block size. The amount of real memory touched is proportional to the size of the file, since the file is smaller than a block. For example, compressing a file 20,000 bytes long with the flag -9 will cause the compressor to allocate around 7600k of memory, but only touch 400k + 20000 * 8 = 560 kbytes of it. Similarly, the decompressor will allocate 3700k but only touch 100k + 20000 * 4 = 180 kbytes. Here is a table which summarises the maximum memory usage for different block sizes. Also recorded is the total compressed size for 14 files of the Calgary Text Compres? sion Corpus totalling 3,141,622 bytes. This column gives some feel for how compression varies with block size. These figures tend to understate the advantage of larger block sizes for larger files, since the Corpus is domi? nated by smaller files. Compress Decompress Decompress Corpus Flag usage usage -s usage Size -1 1200k 500k 350k 914704 -2 2000k 900k 600k 877703 -3 2800k 1300k 850k 860338 -4 3600k 1700k 1100k 846899 -5 4400k 2100k 1350k 845160 -6 5200k 2500k 1600k 838626 -7 6100k 2900k 1850k 834096 -8 6800k 3300k 2100k 828642 -9 7600k 3700k 2350k 828642 RECOVERING DATA FROM DAMAGED FILES bzip2 compresses files in blocks, usually 900kbytes long. Each block is handled independently. If a media or trans? mission error causes a multi-block .bz2 file to become damaged, it may be possible to recover data from the undamaged blocks in the file. The compressed representation of each block is delimited by a 48-bit pattern, which makes it possible to find the block boundaries with reasonable certainty. Each block also carries its own 32-bit CRC, so damaged blocks can be distinguished from undamaged ones. bzip2recover is a simple program whose purpose is to search for blocks in .bz2 files, and write each block out into its own .bz2 file. You can then use bzip2 -t to test the integrity of the resulting files, and decompress those which are undamaged. bzip2recover takes a single argument, the name of the dam? aged file, and writes a number of files "rec00001file.bz2", "rec00002file.bz2", etc, containing the extracted blocks. The output filenames are designed so that the use of wildcards in subsequent pro? cessing -- for example, "bzip2 -dc rec*file.bz2 > recov? ered_data" -- processes the files in the correct order. bzip2recover should be of most use dealing with large .bz2 files, as these will contain many blocks. It is clearly futile to use it on damaged single-block files, since a damaged block cannot be recovered. If you wish to min? imise any potential data loss through media or transmis? sion errors, you might consider compressing with a smaller block size. PERFORMANCE NOTES The sorting phase of compression gathers together similar strings in the file. Because of this, files containing very long runs of repeated symbols, like "aabaabaabaab ..." (repeated several hundred times) may compress more slowly than normal. Versions 0.9.5 and above fare much better than previous versions in this respect. The ratio between worst-case and average-case compression time is in the region of 10:1. For previous versions, this figure was more like 100:1. You can use the -vvvv option to mon? itor progress in great detail, if you want. Decompression speed is unaffected by these phenomena. bzip2 usually allocates several megabytes of memory to operate in, and then charges all over it in a fairly ran? dom fashion. This means that performance, both for com? pressing and decompressing, is largely determined by the speed at which your machine can service cache misses. Because of this, small changes to the code to reduce the miss rate have been observed to give disproportionately large performance improvements. I imagine bzip2 will per? form best on machines with very large caches. CAVEATS I/O error messages are not as helpful as they could be. bzip2 tries hard to detect I/O errors and exit cleanly, but the details of what the problem is sometimes seem rather misleading. This manual page pertains to version 1.0.2 of bzip2. Com? pressed data created by this version is entirely forwards and backwards compatible with the previous public releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0 and 1.0.1, but with the following exception: 0.9.0 and above can cor? rectly decompress multiple concatenated compressed files. 0.1pl2 cannot do this; it will stop after decompressing just the first file in the stream. bzip2recover versions prior to this one, 1.0.2, used 32-bit integers to represent bit positions in compressed files, so it could not handle compressed files more than 512 megabytes long. Version 1.0.2 and above uses 64-bit ints on some platforms which support them (GNU supported targets, and Windows). To establish whether or not bzip2recover was built with such a limitation, run it without arguments. In any event you can build yourself an unlimited version if you can recompile it with MaybeUInt64 set to be an unsigned 64-bit integer. AUTHOR Julian Seward, jseward at acm.org. http://sources.redhat.com/bzip2 The ideas embodied in bzip2 are due to (at least) the fol? lowing people: Michael Burrows and David Wheeler (for the block sorting transformation), David Wheeler (again, for the Huffman coder), Peter Fenwick (for the structured cod? ing model in the original bzip, and many refinements), and Alistair Moffat, Radford Neal and Ian Witten (for the arithmetic coder in the original bzip). I am much indebted for their help, support and advice. See the man? ual in the source distribution for pointers to sources of documentation. Christian von Roques encouraged me to look for faster sorting algorithms, so as to speed up compres? sion. Bela Lubkin encouraged me to improve the worst-case compression performance. The bz* scripts are derived from those of GNU gzip. Many people sent patches, helped with portability problems, lent machines, gave advice and were generally helpful. --- NEW FILE: bzip2recover.c --- /*-----------------------------------------------------------*/ /*--- Block recoverer program for bzip2 ---*/ /*--- bzip2recover.c ---*/ /*-----------------------------------------------------------*/ /*-- This program is bzip2recover, a program to attempt data salvage from damaged files created by the accompanying bzip2-1.0 program. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. jseward at acm.org bzip2/libbzip2 version 1.0 of 21 March 2000 --*/ /*-- This program is a complete hack and should be rewritten properly. It isn't very complicated. --*/ #include #include #include #include /* This program records bit locations in the file to be recovered. That means that if 64-bit ints are not supported, we will not be able to recover .bz2 files over 512MB (2^32 bits) long. On GNU supported platforms, we take advantage of the 64-bit int support to circumvent this problem. Ditto MSVC. This change occurred in version 1.0.2; all prior versions have the 512MB limitation. */ #ifdef __GNUC__ typedef unsigned long long int MaybeUInt64; # define MaybeUInt64_FMT "%Lu" #else #ifdef _MSC_VER typedef unsigned __int64 MaybeUInt64; # define MaybeUInt64_FMT "%I64u" #else typedef unsigned int MaybeUInt64; # define MaybeUInt64_FMT "%u" #endif #endif typedef unsigned int UInt32; typedef int Int32; typedef unsigned char UChar; typedef char Char; typedef unsigned char Bool; #define True ((Bool)1) #define False ((Bool)0) #define BZ_MAX_FILENAME 2000 Char inFileName[BZ_MAX_FILENAME]; Char outFileName[BZ_MAX_FILENAME]; Char progName[BZ_MAX_FILENAME]; MaybeUInt64 bytesOut = 0; MaybeUInt64 bytesIn = 0; /*---------------------------------------------------*/ /*--- Header bytes ---*/ /*---------------------------------------------------*/ #define BZ_HDR_B 0x42 /* 'B' */ #define BZ_HDR_Z 0x5a /* 'Z' */ #define BZ_HDR_h 0x68 /* 'h' */ #define BZ_HDR_0 0x30 /* '0' */ /*---------------------------------------------------*/ /*--- I/O errors ---*/ /*---------------------------------------------------*/ /*---------------------------------------------*/ void readError ( void ) { fprintf ( stderr, "%s: I/O error reading `%s', possible reason follows.\n", progName, inFileName ); perror ( progName ); fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n", progName ); exit ( 1 ); } /*---------------------------------------------*/ void writeError ( void ) { fprintf ( stderr, "%s: I/O error reading `%s', possible reason follows.\n", progName, inFileName ); perror ( progName ); fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n", progName ); exit ( 1 ); } /*---------------------------------------------*/ void mallocFail ( Int32 n ) { fprintf ( stderr, "%s: malloc failed on request for %d bytes.\n", progName, n ); fprintf ( stderr, "%s: warning: output file(s) may be incomplete.\n", progName ); exit ( 1 ); } /*---------------------------------------------*/ void tooManyBlocks ( Int32 max_handled_blocks ) { fprintf ( stderr, "%s: `%s' appears to contain more than %d blocks\n", progName, inFileName, max_handled_blocks ); fprintf ( stderr, "%s: and cannot be handled. To fix, increase\n", progName ); fprintf ( stderr, "%s: BZ_MAX_HANDLED_BLOCKS in bzip2recover.c, and recompile.\n", progName ); exit ( 1 ); } /*---------------------------------------------------*/ /*--- Bit stream I/O ---*/ /*---------------------------------------------------*/ typedef struct { FILE* handle; Int32 buffer; Int32 buffLive; Char mode; } BitStream; /*---------------------------------------------*/ BitStream* bsOpenReadStream ( FILE* stream ) { BitStream *bs = malloc ( sizeof(BitStream) ); if (bs == NULL) mallocFail ( sizeof(BitStream) ); bs->handle = stream; bs->buffer = 0; bs->buffLive = 0; bs->mode = 'r'; return bs; } /*---------------------------------------------*/ BitStream* bsOpenWriteStream ( FILE* stream ) { BitStream *bs = malloc ( sizeof(BitStream) ); if (bs == NULL) mallocFail ( sizeof(BitStream) ); bs->handle = stream; bs->buffer = 0; bs->buffLive = 0; bs->mode = 'w'; return bs; } /*---------------------------------------------*/ void bsPutBit ( BitStream* bs, Int32 bit ) { if (bs->buffLive == 8) { Int32 retVal = putc ( (UChar) bs->buffer, bs->handle ); if (retVal == EOF) writeError(); bytesOut++; bs->buffLive = 1; bs->buffer = bit & 0x1; } else { bs->buffer = ( (bs->buffer << 1) | (bit & 0x1) ); bs->buffLive++; }; } /*---------------------------------------------*/ /*-- Returns 0 or 1, or 2 to indicate EOF. --*/ Int32 bsGetBit ( BitStream* bs ) { if (bs->buffLive > 0) { bs->buffLive --; return ( ((bs->buffer) >> (bs->buffLive)) & 0x1 ); } else { Int32 retVal = getc ( bs->handle ); if ( retVal == EOF ) { if (errno != 0) readError(); return 2; } bs->buffLive = 7; bs->buffer = retVal; return ( ((bs->buffer) >> 7) & 0x1 ); } } /*---------------------------------------------*/ void bsClose ( BitStream* bs ) { Int32 retVal; if ( bs->mode == 'w' ) { while ( bs->buffLive < 8 ) { bs->buffLive++; bs->buffer <<= 1; }; retVal = putc ( (UChar) (bs->buffer), bs->handle ); if (retVal == EOF) writeError(); bytesOut++; retVal = fflush ( bs->handle ); if (retVal == EOF) writeError(); } retVal = fclose ( bs->handle ); if (retVal == EOF) { if (bs->mode == 'w') writeError(); else readError(); } free ( bs ); } /*---------------------------------------------*/ void bsPutUChar ( BitStream* bs, UChar c ) { Int32 i; for (i = 7; i >= 0; i--) bsPutBit ( bs, (((UInt32) c) >> i) & 0x1 ); } /*---------------------------------------------*/ void bsPutUInt32 ( BitStream* bs, UInt32 c ) { Int32 i; for (i = 31; i >= 0; i--) bsPutBit ( bs, (c >> i) & 0x1 ); } /*---------------------------------------------*/ Bool endsInBz2 ( Char* name ) { Int32 n = strlen ( name ); if (n <= 4) return False; return (name[n-4] == '.' && name[n-3] == 'b' && name[n-2] == 'z' && name[n-1] == '2'); } /*---------------------------------------------------*/ /*--- ---*/ /*---------------------------------------------------*/ /* This logic isn't really right when it comes to Cygwin. */ #ifdef _WIN32 # define BZ_SPLIT_SYM '\\' /* path splitter on Windows platform */ #else # define BZ_SPLIT_SYM '/' /* path splitter on Unix platform */ #endif #define BLOCK_HEADER_HI 0x00003141UL #define BLOCK_HEADER_LO 0x59265359UL #define BLOCK_ENDMARK_HI 0x00001772UL #define BLOCK_ENDMARK_LO 0x45385090UL /* Increase if necessary. However, a .bz2 file with > 50000 blocks would have an uncompressed size of at least 40GB, so the chances are low you'll need to up this. */ #define BZ_MAX_HANDLED_BLOCKS 50000 MaybeUInt64 bStart [BZ_MAX_HANDLED_BLOCKS]; MaybeUInt64 bEnd [BZ_MAX_HANDLED_BLOCKS]; MaybeUInt64 rbStart[BZ_MAX_HANDLED_BLOCKS]; MaybeUInt64 rbEnd [BZ_MAX_HANDLED_BLOCKS]; Int32 main ( Int32 argc, Char** argv ) { FILE* inFile; FILE* outFile; BitStream* bsIn, *bsWr; Int32 b, wrBlock, currBlock, rbCtr; MaybeUInt64 bitsRead; UInt32 buffHi, buffLo, blockCRC; Char* p; strcpy ( progName, argv[0] ); inFileName[0] = outFileName[0] = 0; fprintf ( stderr, "bzip2recover 1.0.2: extracts blocks from damaged .bz2 files.\n" ); if (argc != 2) { fprintf ( stderr, "%s: usage is `%s damaged_file_name'.\n", progName, progName ); switch (sizeof(MaybeUInt64)) { case 8: fprintf(stderr, "\trestrictions on size of recovered file: None\n"); break; case 4: fprintf(stderr, "\trestrictions on size of recovered file: 512 MB\n"); fprintf(stderr, "\tto circumvent, recompile with MaybeUInt64 as an\n" "\tunsigned 64-bit int.\n"); break; default: fprintf(stderr, "\tsizeof(MaybeUInt64) is not 4 or 8 -- " "configuration error.\n"); break; } exit(1); } if (strlen(argv[1]) >= BZ_MAX_FILENAME-20) { fprintf ( stderr, "%s: supplied filename is suspiciously (>= %d chars) long. Bye!\n", progName, strlen(argv[1]) ); exit(1); } strcpy ( inFileName, argv[1] ); inFile = fopen ( inFileName, "rb" ); if (inFile == NULL) { fprintf ( stderr, "%s: can't read `%s'\n", progName, inFileName ); exit(1); } bsIn = bsOpenReadStream ( inFile ); fprintf ( stderr, "%s: searching for block boundaries ...\n", progName ); bitsRead = 0; buffHi = buffLo = 0; currBlock = 0; bStart[currBlock] = 0; rbCtr = 0; while (True) { b = bsGetBit ( bsIn ); bitsRead++; if (b == 2) { if (bitsRead >= bStart[currBlock] && (bitsRead - bStart[currBlock]) >= 40) { bEnd[currBlock] = bitsRead-1; if (currBlock > 0) fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT " to " MaybeUInt64_FMT " (incomplete)\n", currBlock, bStart[currBlock], bEnd[currBlock] ); } else currBlock--; break; } buffHi = (buffHi << 1) | (buffLo >> 31); buffLo = (buffLo << 1) | (b & 1); if ( ( (buffHi & 0x0000ffff) == BLOCK_HEADER_HI && buffLo == BLOCK_HEADER_LO) || ( (buffHi & 0x0000ffff) == BLOCK_ENDMARK_HI && buffLo == BLOCK_ENDMARK_LO) ) { if (bitsRead > 49) { bEnd[currBlock] = bitsRead-49; } else { bEnd[currBlock] = 0; } if (currBlock > 0 && (bEnd[currBlock] - bStart[currBlock]) >= 130) { fprintf ( stderr, " block %d runs from " MaybeUInt64_FMT " to " MaybeUInt64_FMT "\n", rbCtr+1, bStart[currBlock], bEnd[currBlock] ); rbStart[rbCtr] = bStart[currBlock]; rbEnd[rbCtr] = bEnd[currBlock]; rbCtr++; } if (currBlock >= BZ_MAX_HANDLED_BLOCKS) tooManyBlocks(BZ_MAX_HANDLED_BLOCKS); currBlock++; bStart[currBlock] = bitsRead; } } bsClose ( bsIn ); /*-- identified blocks run from 1 to rbCtr inclusive. --*/ if (rbCtr < 1) { fprintf ( stderr, "%s: sorry, I couldn't find any block boundaries.\n", progName ); exit(1); }; fprintf ( stderr, "%s: splitting into blocks\n", progName ); inFile = fopen ( inFileName, "rb" ); if (inFile == NULL) { fprintf ( stderr, "%s: can't open `%s'\n", progName, inFileName ); exit(1); } bsIn = bsOpenReadStream ( inFile ); /*-- placate gcc's dataflow analyser --*/ blockCRC = 0; bsWr = 0; bitsRead = 0; outFile = NULL; wrBlock = 0; while (True) { b = bsGetBit(bsIn); if (b == 2) break; buffHi = (buffHi << 1) | (buffLo >> 31); buffLo = (buffLo << 1) | (b & 1); if (bitsRead == 47+rbStart[wrBlock]) blockCRC = (buffHi << 16) | (buffLo >> 16); if (outFile != NULL && bitsRead >= rbStart[wrBlock] && bitsRead <= rbEnd[wrBlock]) { bsPutBit ( bsWr, b ); } bitsRead++; if (bitsRead == rbEnd[wrBlock]+1) { if (outFile != NULL) { bsPutUChar ( bsWr, 0x17 ); bsPutUChar ( bsWr, 0x72 ); bsPutUChar ( bsWr, 0x45 ); bsPutUChar ( bsWr, 0x38 ); bsPutUChar ( bsWr, 0x50 ); bsPutUChar ( bsWr, 0x90 ); bsPutUInt32 ( bsWr, blockCRC ); bsClose ( bsWr ); } if (wrBlock >= rbCtr) break; wrBlock++; } else if (bitsRead == rbStart[wrBlock]) { /* Create the output file name, correctly handling leading paths. (31.10.2001 by Sergey E. Kusikov) */ Char* split; Int32 ofs, k; for (k = 0; k < BZ_MAX_FILENAME; k++) outFileName[k] = 0; strcpy (outFileName, inFileName); split = strrchr (outFileName, BZ_SPLIT_SYM); if (split == NULL) { split = outFileName; } else { ++split; } /* Now split points to the start of the basename. */ ofs = split - outFileName; sprintf (split, "rec%5d", wrBlock+1); for (p = split; *p != 0; p++) if (*p == ' ') *p = '0'; strcat (outFileName, inFileName + ofs); if ( !endsInBz2(outFileName)) strcat ( outFileName, ".bz2" ); fprintf ( stderr, " writing block %d to `%s' ...\n", wrBlock+1, outFileName ); outFile = fopen ( outFileName, "wb" ); if (outFile == NULL) { fprintf ( stderr, "%s: can't write `%s'\n", progName, outFileName ); exit(1); } bsWr = bsOpenWriteStream ( outFile ); bsPutUChar ( bsWr, BZ_HDR_B ); bsPutUChar ( bsWr, BZ_HDR_Z ); bsPutUChar ( bsWr, BZ_HDR_h ); bsPutUChar ( bsWr, BZ_HDR_0 + 9 ); bsPutUChar ( bsWr, 0x31 ); bsPutUChar ( bsWr, 0x41 ); bsPutUChar ( bsWr, 0x59 ); bsPutUChar ( bsWr, 0x26 ); bsPutUChar ( bsWr, 0x53 ); bsPutUChar ( bsWr, 0x59 ); } } fprintf ( stderr, "%s: finished\n", progName ); return 0; } /*-----------------------------------------------------------*/ /*--- end bzip2recover.c ---*/ /*-----------------------------------------------------------*/ --- NEW FILE: bzlib.c --- /*-------------------------------------------------------------*/ /*--- Library top-level functions. ---*/ /*--- bzlib.c ---*/ /*-------------------------------------------------------------*/ /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. [...1554 lines suppressed...] ,"???" /* for future */ ,"???" /* for future */ ,"???" /* for future */ }; const char * BZ_API(BZ2_bzerror) (BZFILE *b, int *errnum) { int err = ((bzFile *)b)->lastErr; if(err>0) err = 0; *errnum = err; return bzerrorstrings[err*-1]; } #endif /*-------------------------------------------------------------*/ /*--- end bzlib.c ---*/ /*-------------------------------------------------------------*/ --- NEW FILE: bzlib.h --- /*-------------------------------------------------------------*/ /*--- Public header file for the library. ---*/ /*--- bzlib.h ---*/ /*-------------------------------------------------------------*/ /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. jseward at acm.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: Mike Burrows David Wheeler Peter Fenwick Alistair Moffat Radford Neal Ian H. Witten Robert Sedgewick Jon L. Bentley For more information on these sources, see the manual. --*/ #ifndef _BZLIB_H #define _BZLIB_H #ifdef __cplusplus extern "C" { #endif #define BZ_RUN 0 #define BZ_FLUSH 1 #define BZ_FINISH 2 #define BZ_OK 0 #define BZ_RUN_OK 1 #define BZ_FLUSH_OK 2 #define BZ_FINISH_OK 3 #define BZ_STREAM_END 4 #define BZ_SEQUENCE_ERROR (-1) #define BZ_PARAM_ERROR (-2) #define BZ_MEM_ERROR (-3) #define BZ_DATA_ERROR (-4) #define BZ_DATA_ERROR_MAGIC (-5) #define BZ_IO_ERROR (-6) #define BZ_UNEXPECTED_EOF (-7) #define BZ_OUTBUFF_FULL (-8) #define BZ_CONFIG_ERROR (-9) typedef struct { char *next_in; unsigned int avail_in; unsigned int total_in_lo32; unsigned int total_in_hi32; char *next_out; unsigned int avail_out; unsigned int total_out_lo32; unsigned int total_out_hi32; void *state; void *(*bzalloc)(void *,int,int); void (*bzfree)(void *,void *); void *opaque; } bz_stream; #ifndef BZ_IMPORT #define BZ_EXPORT #endif /* Need a definitition for FILE */ #include #ifdef _WIN32 # include # ifdef small /* windows.h define small to char */ # undef small # endif # ifdef BZ_EXPORT # define BZ_API(func) WINAPI func # define BZ_EXTERN extern # else /* import windows dll dynamically */ # define BZ_API(func) (WINAPI * func) # define BZ_EXTERN # endif #else # define BZ_API(func) func # define BZ_EXTERN extern #endif /*-- Core (low-level) library functions --*/ BZ_EXTERN int BZ_API(BZ2_bzCompressInit) ( bz_stream* strm, int blockSize100k, int verbosity, int workFactor ); BZ_EXTERN int BZ_API(BZ2_bzCompress) ( bz_stream* strm, int action ); BZ_EXTERN int BZ_API(BZ2_bzCompressEnd) ( bz_stream* strm ); BZ_EXTERN int BZ_API(BZ2_bzDecompressInit) ( bz_stream *strm, int verbosity, int small ); BZ_EXTERN int BZ_API(BZ2_bzDecompress) ( bz_stream* strm ); BZ_EXTERN int BZ_API(BZ2_bzDecompressEnd) ( bz_stream *strm ); /*-- High(er) level library functions --*/ #ifndef BZ_NO_STDIO #define BZ_MAX_UNUSED 5000 typedef void BZFILE; BZ_EXTERN BZFILE* BZ_API(BZ2_bzReadOpen) ( int* bzerror, FILE* f, int verbosity, int small, void* unused, int nUnused ); BZ_EXTERN void BZ_API(BZ2_bzReadClose) ( int* bzerror, BZFILE* b ); BZ_EXTERN void BZ_API(BZ2_bzReadGetUnused) ( int* bzerror, BZFILE* b, void** unused, int* nUnused ); BZ_EXTERN int BZ_API(BZ2_bzRead) ( int* bzerror, BZFILE* b, void* buf, int len ); BZ_EXTERN BZFILE* BZ_API(BZ2_bzWriteOpen) ( int* bzerror, FILE* f, int blockSize100k, int verbosity, int workFactor ); BZ_EXTERN void BZ_API(BZ2_bzWrite) ( int* bzerror, BZFILE* b, void* buf, int len ); BZ_EXTERN void BZ_API(BZ2_bzWriteClose) ( int* bzerror, BZFILE* b, int abandon, unsigned int* nbytes_in, unsigned int* nbytes_out ); BZ_EXTERN void BZ_API(BZ2_bzWriteClose64) ( int* bzerror, BZFILE* b, int abandon, unsigned int* nbytes_in_lo32, unsigned int* nbytes_in_hi32, unsigned int* nbytes_out_lo32, unsigned int* nbytes_out_hi32 ); #endif /*-- Utility functions --*/ BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffCompress) ( char* dest, unsigned int* destLen, char* source, unsigned int sourceLen, int blockSize100k, int verbosity, int workFactor ); BZ_EXTERN int BZ_API(BZ2_bzBuffToBuffDecompress) ( char* dest, unsigned int* destLen, char* source, unsigned int sourceLen, int small, int verbosity ); /*-- Code contributed by Yoshioka Tsuneo (QWF00133 at niftyserve.or.jp/tsuneo-y at is.aist-nara.ac.jp), to support better zlib compatibility. This code is not _officially_ part of libbzip2 (yet); I haven't tested it, documented it, or considered the threading-safeness of it. If this code breaks, please contact both Yoshioka and me. --*/ BZ_EXTERN const char * BZ_API(BZ2_bzlibVersion) ( void ); #ifndef BZ_NO_STDIO BZ_EXTERN BZFILE * BZ_API(BZ2_bzopen) ( const char *path, const char *mode ); BZ_EXTERN BZFILE * BZ_API(BZ2_bzdopen) ( int fd, const char *mode ); BZ_EXTERN int BZ_API(BZ2_bzread) ( BZFILE* b, void* buf, int len ); BZ_EXTERN int BZ_API(BZ2_bzwrite) ( BZFILE* b, void* buf, int len ); BZ_EXTERN int BZ_API(BZ2_bzflush) ( BZFILE* b ); BZ_EXTERN void BZ_API(BZ2_bzclose) ( BZFILE* b ); BZ_EXTERN const char * BZ_API(BZ2_bzerror) ( BZFILE *b, int *errnum ); #endif #ifdef __cplusplus } #endif #endif /*-------------------------------------------------------------*/ /*--- end bzlib.h ---*/ /*-------------------------------------------------------------*/ --- NEW FILE: bzlib_private.h --- /*-------------------------------------------------------------*/ /*--- Private header file for the library. ---*/ /*--- bzlib_private.h ---*/ /*-------------------------------------------------------------*/ /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. jseward at acm.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: Mike Burrows David Wheeler Peter Fenwick Alistair Moffat Radford Neal Ian H. Witten Robert Sedgewick Jon L. Bentley For more information on these sources, see the manual. --*/ #ifndef _BZLIB_PRIVATE_H #define _BZLIB_PRIVATE_H #include #ifndef BZ_NO_STDIO #include #include #include #endif #include "bzlib.h" /*-- General stuff. --*/ #define BZ_VERSION "1.0.2, 30-Dec-2001" typedef char Char; typedef unsigned char Bool; typedef unsigned char UChar; typedef int Int32; typedef unsigned int UInt32; typedef short Int16; typedef unsigned short UInt16; #define True ((Bool)1) #define False ((Bool)0) #ifndef __GNUC__ #define __inline__ /* */ #endif #ifndef BZ_NO_STDIO extern void BZ2_bz__AssertH__fail ( int errcode ); #define AssertH(cond,errcode) \ { if (!(cond)) BZ2_bz__AssertH__fail ( errcode ); } #if BZ_DEBUG #define AssertD(cond,msg) \ { if (!(cond)) { \ fprintf ( stderr, \ "\n\nlibbzip2(debug build): internal error\n\t%s\n", msg );\ exit(1); \ }} #else #define AssertD(cond,msg) /* */ #endif #define VPrintf0(zf) \ fprintf(stderr,zf) #define VPrintf1(zf,za1) \ fprintf(stderr,zf,za1) #define VPrintf2(zf,za1,za2) \ fprintf(stderr,zf,za1,za2) #define VPrintf3(zf,za1,za2,za3) \ fprintf(stderr,zf,za1,za2,za3) #define VPrintf4(zf,za1,za2,za3,za4) \ fprintf(stderr,zf,za1,za2,za3,za4) #define VPrintf5(zf,za1,za2,za3,za4,za5) \ fprintf(stderr,zf,za1,za2,za3,za4,za5) #else extern void bz_internal_error ( int errcode ); #define AssertH(cond,errcode) \ { if (!(cond)) bz_internal_error ( errcode ); } #define AssertD(cond,msg) /* */ #define VPrintf0(zf) /* */ #define VPrintf1(zf,za1) /* */ #define VPrintf2(zf,za1,za2) /* */ #define VPrintf3(zf,za1,za2,za3) /* */ #define VPrintf4(zf,za1,za2,za3,za4) /* */ #define VPrintf5(zf,za1,za2,za3,za4,za5) /* */ #endif #define BZALLOC(nnn) (strm->bzalloc)(strm->opaque,(nnn),1) #define BZFREE(ppp) (strm->bzfree)(strm->opaque,(ppp)) /*-- Header bytes. --*/ #define BZ_HDR_B 0x42 /* 'B' */ #define BZ_HDR_Z 0x5a /* 'Z' */ #define BZ_HDR_h 0x68 /* 'h' */ #define BZ_HDR_0 0x30 /* '0' */ /*-- Constants for the back end. --*/ #define BZ_MAX_ALPHA_SIZE 258 #define BZ_MAX_CODE_LEN 23 #define BZ_RUNA 0 #define BZ_RUNB 1 #define BZ_N_GROUPS 6 #define BZ_G_SIZE 50 #define BZ_N_ITERS 4 #define BZ_MAX_SELECTORS (2 + (900000 / BZ_G_SIZE)) /*-- Stuff for randomising repetitive blocks. --*/ extern Int32 BZ2_rNums[512]; #define BZ_RAND_DECLS \ Int32 rNToGo; \ Int32 rTPos \ #define BZ_RAND_INIT_MASK \ s->rNToGo = 0; \ s->rTPos = 0 \ #define BZ_RAND_MASK ((s->rNToGo == 1) ? 1 : 0) #define BZ_RAND_UPD_MASK \ if (s->rNToGo == 0) { \ s->rNToGo = BZ2_rNums[s->rTPos]; \ s->rTPos++; \ if (s->rTPos == 512) s->rTPos = 0; \ } \ s->rNToGo--; /*-- Stuff for doing CRCs. --*/ extern UInt32 BZ2_crc32Table[256]; #define BZ_INITIALISE_CRC(crcVar) \ { \ crcVar = 0xffffffffL; \ } #define BZ_FINALISE_CRC(crcVar) \ { \ crcVar = ~(crcVar); \ } #define BZ_UPDATE_CRC(crcVar,cha) \ { \ crcVar = (crcVar << 8) ^ \ BZ2_crc32Table[(crcVar >> 24) ^ \ ((UChar)cha)]; \ } /*-- States and modes for compression. --*/ #define BZ_M_IDLE 1 #define BZ_M_RUNNING 2 #define BZ_M_FLUSHING 3 #define BZ_M_FINISHING 4 #define BZ_S_OUTPUT 1 #define BZ_S_INPUT 2 #define BZ_N_RADIX 2 #define BZ_N_QSORT 12 #define BZ_N_SHELL 18 #define BZ_N_OVERSHOOT (BZ_N_RADIX + BZ_N_QSORT + BZ_N_SHELL + 2) /*-- Structure holding all the compression-side stuff. --*/ typedef struct { /* pointer back to the struct bz_stream */ bz_stream* strm; /* mode this stream is in, and whether inputting */ /* or outputting data */ Int32 mode; Int32 state; /* remembers avail_in when flush/finish requested */ UInt32 avail_in_expect; /* for doing the block sorting */ UInt32* arr1; UInt32* arr2; UInt32* ftab; Int32 origPtr; /* aliases for arr1 and arr2 */ UInt32* ptr; UChar* block; UInt16* mtfv; UChar* zbits; /* for deciding when to use the fallback sorting algorithm */ Int32 workFactor; /* run-length-encoding of the input */ UInt32 state_in_ch; Int32 state_in_len; BZ_RAND_DECLS; /* input and output limits and current posns */ Int32 nblock; Int32 nblockMAX; Int32 numZ; Int32 state_out_pos; /* map of bytes used in block */ Int32 nInUse; Bool inUse[256]; UChar unseqToSeq[256]; /* the buffer for bit stream creation */ UInt32 bsBuff; Int32 bsLive; /* block and combined CRCs */ UInt32 blockCRC; UInt32 combinedCRC; /* misc administratium */ Int32 verbosity; Int32 blockNo; Int32 blockSize100k; /* stuff for coding the MTF values */ Int32 nMTF; Int32 mtfFreq [BZ_MAX_ALPHA_SIZE]; UChar selector [BZ_MAX_SELECTORS]; UChar selectorMtf[BZ_MAX_SELECTORS]; UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; Int32 code [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; Int32 rfreq [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; /* second dimension: only 3 needed; 4 makes index calculations faster */ UInt32 len_pack[BZ_MAX_ALPHA_SIZE][4]; } EState; /*-- externs for compression. --*/ extern void BZ2_blockSort ( EState* ); extern void BZ2_compressBlock ( EState*, Bool ); extern void BZ2_bsInitWrite ( EState* ); extern void BZ2_hbAssignCodes ( Int32*, UChar*, Int32, Int32, Int32 ); extern void BZ2_hbMakeCodeLengths ( UChar*, Int32*, Int32, Int32 ); /*-- states for decompression. --*/ #define BZ_X_IDLE 1 #define BZ_X_OUTPUT 2 #define BZ_X_MAGIC_1 10 #define BZ_X_MAGIC_2 11 #define BZ_X_MAGIC_3 12 #define BZ_X_MAGIC_4 13 #define BZ_X_BLKHDR_1 14 #define BZ_X_BLKHDR_2 15 #define BZ_X_BLKHDR_3 16 #define BZ_X_BLKHDR_4 17 #define BZ_X_BLKHDR_5 18 #define BZ_X_BLKHDR_6 19 #define BZ_X_BCRC_1 20 #define BZ_X_BCRC_2 21 #define BZ_X_BCRC_3 22 #define BZ_X_BCRC_4 23 #define BZ_X_RANDBIT 24 #define BZ_X_ORIGPTR_1 25 #define BZ_X_ORIGPTR_2 26 #define BZ_X_ORIGPTR_3 27 #define BZ_X_MAPPING_1 28 #define BZ_X_MAPPING_2 29 #define BZ_X_SELECTOR_1 30 #define BZ_X_SELECTOR_2 31 #define BZ_X_SELECTOR_3 32 #define BZ_X_CODING_1 33 #define BZ_X_CODING_2 34 #define BZ_X_CODING_3 35 #define BZ_X_MTF_1 36 #define BZ_X_MTF_2 37 #define BZ_X_MTF_3 38 #define BZ_X_MTF_4 39 #define BZ_X_MTF_5 40 #define BZ_X_MTF_6 41 #define BZ_X_ENDHDR_2 42 #define BZ_X_ENDHDR_3 43 #define BZ_X_ENDHDR_4 44 #define BZ_X_ENDHDR_5 45 #define BZ_X_ENDHDR_6 46 #define BZ_X_CCRC_1 47 #define BZ_X_CCRC_2 48 #define BZ_X_CCRC_3 49 #define BZ_X_CCRC_4 50 /*-- Constants for the fast MTF decoder. --*/ #define MTFA_SIZE 4096 #define MTFL_SIZE 16 /*-- Structure holding all the decompression-side stuff. --*/ typedef struct { /* pointer back to the struct bz_stream */ bz_stream* strm; /* state indicator for this stream */ Int32 state; /* for doing the final run-length decoding */ UChar state_out_ch; Int32 state_out_len; Bool blockRandomised; BZ_RAND_DECLS; /* the buffer for bit stream reading */ UInt32 bsBuff; Int32 bsLive; /* misc administratium */ Int32 blockSize100k; Bool smallDecompress; Int32 currBlockNo; Int32 verbosity; /* for undoing the Burrows-Wheeler transform */ Int32 origPtr; UInt32 tPos; Int32 k0; Int32 unzftab[256]; Int32 nblock_used; Int32 cftab[257]; Int32 cftabCopy[257]; /* for undoing the Burrows-Wheeler transform (FAST) */ UInt32 *tt; /* for undoing the Burrows-Wheeler transform (SMALL) */ UInt16 *ll16; UChar *ll4; /* stored and calculated CRCs */ UInt32 storedBlockCRC; UInt32 storedCombinedCRC; UInt32 calculatedBlockCRC; UInt32 calculatedCombinedCRC; /* map of bytes used in block */ Int32 nInUse; Bool inUse[256]; Bool inUse16[16]; UChar seqToUnseq[256]; /* for decoding the MTF values */ UChar mtfa [MTFA_SIZE]; Int32 mtfbase[256 / MTFL_SIZE]; UChar selector [BZ_MAX_SELECTORS]; UChar selectorMtf[BZ_MAX_SELECTORS]; UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; Int32 limit [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; Int32 base [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; Int32 perm [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; Int32 minLens[BZ_N_GROUPS]; /* save area for scalars in the main decompress code */ Int32 save_i; Int32 save_j; Int32 save_t; Int32 save_alphaSize; Int32 save_nGroups; Int32 save_nSelectors; Int32 save_EOB; Int32 save_groupNo; Int32 save_groupPos; Int32 save_nextSym; Int32 save_nblockMAX; Int32 save_nblock; Int32 save_es; Int32 save_N; Int32 save_curr; Int32 save_zt; Int32 save_zn; Int32 save_zvec; Int32 save_zj; Int32 save_gSel; Int32 save_gMinlen; Int32* save_gLimit; Int32* save_gBase; Int32* save_gPerm; } DState; /*-- Macros for decompression. --*/ #define BZ_GET_FAST(cccc) \ s->tPos = s->tt[s->tPos]; \ cccc = (UChar)(s->tPos & 0xff); \ s->tPos >>= 8; #define BZ_GET_FAST_C(cccc) \ c_tPos = c_tt[c_tPos]; \ cccc = (UChar)(c_tPos & 0xff); \ c_tPos >>= 8; #define SET_LL4(i,n) \ { if (((i) & 0x1) == 0) \ s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0xf0) | (n); else \ s->ll4[(i) >> 1] = (s->ll4[(i) >> 1] & 0x0f) | ((n) << 4); \ } #define GET_LL4(i) \ ((((UInt32)(s->ll4[(i) >> 1])) >> (((i) << 2) & 0x4)) & 0xF) #define SET_LL(i,n) \ { s->ll16[i] = (UInt16)(n & 0x0000ffff); \ SET_LL4(i, n >> 16); \ } #define GET_LL(i) \ (((UInt32)s->ll16[i]) | (GET_LL4(i) << 16)) #define BZ_GET_SMALL(cccc) \ cccc = BZ2_indexIntoF ( s->tPos, s->cftab ); \ s->tPos = GET_LL(s->tPos); /*-- externs for decompression. --*/ extern Int32 BZ2_indexIntoF ( Int32, Int32* ); extern Int32 BZ2_decompress ( DState* ); extern void BZ2_hbCreateDecodeTables ( Int32*, Int32*, Int32*, UChar*, Int32, Int32, Int32 ); #endif /*-- BZ_NO_STDIO seems to make NULL disappear on some platforms. --*/ #ifdef BZ_NO_STDIO #ifndef NULL #define NULL 0 #endif #endif /*-------------------------------------------------------------*/ /*--- end bzlib_private.h ---*/ /*-------------------------------------------------------------*/ --- NEW FILE: bzmore --- #!/bin/sh # Bzmore wrapped for bzip2, # adapted from zmore by Philippe Troin for Debian GNU/Linux. PATH="/usr/bin:$PATH"; export PATH prog=`echo $0 | sed 's|.*/||'` case "$prog" in *less) more=less ;; *) more=more ;; esac if test "`echo -n a`" = "-n a"; then # looks like a SysV system: n1=''; n2='\c' else n1='-n'; n2='' fi oldtty=`stty -g 2>/dev/null` if stty -cbreak 2>/dev/null; then cb='cbreak'; ncb='-cbreak' else # 'stty min 1' resets eof to ^a on both SunOS and SysV! cb='min 1 -icanon'; ncb='icanon eof ^d' fi if test $? -eq 0 -a -n "$oldtty"; then trap 'stty $oldtty 2>/dev/null; exit' 0 2 3 5 10 13 15 else trap 'stty $ncb echo 2>/dev/null; exit' 0 2 3 5 10 13 15 fi if test $# = 0; then if test -t 0; then echo usage: $prog files... else bzip2 -cdfq | eval $more fi else FIRST=1 for FILE do if test $FIRST -eq 0; then echo $n1 "--More--(Next file: $FILE)$n2" stty $cb -echo 2>/dev/null ANS=`dd bs=1 count=1 2>/dev/null` stty $ncb echo 2>/dev/null echo " " if test "$ANS" = 'e' -o "$ANS" = 'q'; then exit fi fi if test "$ANS" != 's'; then echo "------> $FILE <------" bzip2 -cdfq "$FILE" | eval $more fi if test -t; then FIRST=0 fi done fi --- NEW FILE: bzmore.1 --- .\"Shamelessly copied from zmore.1 by Philippe Troin .\"for Debian GNU/Linux .TH BZMORE 1 .SH NAME bzmore, bzless \- file perusal filter for crt viewing of bzip2 compressed text .SH SYNOPSIS .B bzmore [ name ... ] .br .B bzless [ name ... ] .SH NOTE In the following description, .I bzless and .I less can be used interchangeably with .I bzmore and .I more. .SH DESCRIPTION .I Bzmore is a filter which allows examination of compressed or plain text files one screenful at a time on a soft-copy terminal. .I bzmore works on files compressed with .I bzip2 and also on uncompressed files. If a file does not exist, .I bzmore looks for a file of the same name with the addition of a .bz2 suffix. .PP .I Bzmore normally pauses after each screenful, printing --More-- at the bottom of the screen. If the user then types a carriage return, one more line is displayed. If the user hits a space, another screenful is displayed. Other possibilities are enumerated later. .PP .I Bzmore looks in the file .I /etc/termcap to determine terminal characteristics, and to determine the default window size. On a terminal capable of displaying 24 lines, the default window size is 22 lines. Other sequences which may be typed when .I bzmore pauses, and their effects, are as follows (\fIi\fP is an optional integer argument, defaulting to 1) : .PP .IP \fIi\|\fP display .I i more lines, (or another screenful if no argument is given) .PP .IP ^D display 11 more lines (a ``scroll''). If .I i is given, then the scroll size is set to \fIi\|\fP. .PP .IP d same as ^D (control-D) .PP .IP \fIi\|\fPz same as typing a space except that \fIi\|\fP, if present, becomes the new window size. Note that the window size reverts back to the default at the end of the current file. .PP .IP \fIi\|\fPs skip \fIi\|\fP lines and print a screenful of lines .PP .IP \fIi\|\fPf skip \fIi\fP screenfuls and print a screenful of lines .PP .IP "q or Q" quit reading the current file; go on to the next (if any) .PP .IP "e or q" When the prompt --More--(Next file: .IR file ) is printed, this command causes bzmore to exit. .PP .IP s When the prompt --More--(Next file: .IR file ) is printed, this command causes bzmore to skip the next file and continue. .PP .IP = Display the current line number. .PP .IP \fIi\|\fP/expr search for the \fIi\|\fP-th occurrence of the regular expression \fIexpr.\fP If the pattern is not found, .I bzmore goes on to the next file (if any). Otherwise, a screenful is displayed, starting two lines before the place where the expression was found. The user's erase and kill characters may be used to edit the regular expression. Erasing back past the first column cancels the search command. .PP .IP \fIi\|\fPn search for the \fIi\|\fP-th occurrence of the last regular expression entered. .PP .IP !command invoke a shell with \fIcommand\|\fP. The character `!' in "command" are replaced with the previous shell command. The sequence "\\!" is replaced by "!". .PP .IP ":q or :Q" quit reading the current file; go on to the next (if any) (same as q or Q). .PP .IP . (dot) repeat the previous command. .PP The commands take effect immediately, i.e., it is not necessary to type a carriage return. Up to the time when the command character itself is given, the user may hit the line kill character to cancel the numerical argument being formed. In addition, the user may hit the erase character to redisplay the --More-- message. .PP At any time when output is being sent to the terminal, the user can hit the quit key (normally control\-\\). .I Bzmore will stop sending output, and will display the usual --More-- prompt. The user may then enter one of the above commands in the normal manner. Unfortunately, some output is lost when this is done, due to the fact that any characters waiting in the terminal's output queue are flushed when the quit signal occurs. .PP The terminal is set to .I noecho mode by this program so that the output can be continuous. What you type will thus not show on your terminal, except for the / and ! commands. .PP If the standard output is not a teletype, then .I bzmore acts just like .I bzcat, except that a header is printed before each file. .SH FILES .DT /etc/termcap Terminal data base .SH "SEE ALSO" more(1), less(1), bzip2(1), bzdiff(1), bzgrep(1) --- NEW FILE: compress.c --- /*-------------------------------------------------------------*/ /*--- Compression machinery (not incl block sorting) ---*/ /*--- compress.c ---*/ /*-------------------------------------------------------------*/ /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. jseward at acm.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: Mike Burrows David Wheeler Peter Fenwick Alistair Moffat Radford Neal Ian H. Witten Robert Sedgewick Jon L. Bentley For more information on these sources, see the manual. --*/ /*-- CHANGES ~~~~~~~ 0.9.0 -- original version. 0.9.0a/b -- no changes in this file. 0.9.0c * changed setting of nGroups in sendMTFValues() so as to do a bit better on small files --*/ #include "bzlib_private.h" /*---------------------------------------------------*/ /*--- Bit stream I/O ---*/ /*---------------------------------------------------*/ /*---------------------------------------------------*/ void BZ2_bsInitWrite ( EState* s ) { s->bsLive = 0; s->bsBuff = 0; } /*---------------------------------------------------*/ static void bsFinishWrite ( EState* s ) { while (s->bsLive > 0) { s->zbits[s->numZ] = (UChar)(s->bsBuff >> 24); s->numZ++; s->bsBuff <<= 8; s->bsLive -= 8; } } /*---------------------------------------------------*/ #define bsNEEDW(nz) \ { \ while (s->bsLive >= 8) { \ s->zbits[s->numZ] \ = (UChar)(s->bsBuff >> 24); \ s->numZ++; \ s->bsBuff <<= 8; \ s->bsLive -= 8; \ } \ } /*---------------------------------------------------*/ static __inline__ void bsW ( EState* s, Int32 n, UInt32 v ) { bsNEEDW ( n ); s->bsBuff |= (v << (32 - s->bsLive - n)); s->bsLive += n; } /*---------------------------------------------------*/ static void bsPutUInt32 ( EState* s, UInt32 u ) { bsW ( s, 8, (u >> 24) & 0xffL ); bsW ( s, 8, (u >> 16) & 0xffL ); bsW ( s, 8, (u >> 8) & 0xffL ); bsW ( s, 8, u & 0xffL ); } /*---------------------------------------------------*/ static void bsPutUChar ( EState* s, UChar c ) { bsW( s, 8, (UInt32)c ); } /*---------------------------------------------------*/ /*--- The back end proper ---*/ /*---------------------------------------------------*/ /*---------------------------------------------------*/ static void makeMaps_e ( EState* s ) { Int32 i; s->nInUse = 0; for (i = 0; i < 256; i++) if (s->inUse[i]) { s->unseqToSeq[i] = s->nInUse; s->nInUse++; } } /*---------------------------------------------------*/ static void generateMTFValues ( EState* s ) { UChar yy[256]; Int32 i, j; Int32 zPend; Int32 wr; Int32 EOB; /* After sorting (eg, here), s->arr1 [ 0 .. s->nblock-1 ] holds sorted order, and ((UChar*)s->arr2) [ 0 .. s->nblock-1 ] holds the original block data. The first thing to do is generate the MTF values, and put them in ((UInt16*)s->arr1) [ 0 .. s->nblock-1 ]. Because there are strictly fewer or equal MTF values than block values, ptr values in this area are overwritten with MTF values only when they are no longer needed. The final compressed bitstream is generated into the area starting at (UChar*) (&((UChar*)s->arr2)[s->nblock]) These storage aliases are set up in bzCompressInit(), except for the last one, which is arranged in compressBlock(). */ UInt32* ptr = s->ptr; UChar* block = s->block; UInt16* mtfv = s->mtfv; makeMaps_e ( s ); EOB = s->nInUse+1; for (i = 0; i <= EOB; i++) s->mtfFreq[i] = 0; wr = 0; zPend = 0; for (i = 0; i < s->nInUse; i++) yy[i] = (UChar) i; for (i = 0; i < s->nblock; i++) { UChar ll_i; AssertD ( wr <= i, "generateMTFValues(1)" ); j = ptr[i]-1; if (j < 0) j += s->nblock; ll_i = s->unseqToSeq[block[j]]; AssertD ( ll_i < s->nInUse, "generateMTFValues(2a)" ); if (yy[0] == ll_i) { zPend++; } else { if (zPend > 0) { zPend--; while (True) { if (zPend & 1) { mtfv[wr] = BZ_RUNB; wr++; s->mtfFreq[BZ_RUNB]++; } else { mtfv[wr] = BZ_RUNA; wr++; s->mtfFreq[BZ_RUNA]++; } if (zPend < 2) break; zPend = (zPend - 2) / 2; }; zPend = 0; } { register UChar rtmp; register UChar* ryy_j; register UChar rll_i; rtmp = yy[1]; yy[1] = yy[0]; ryy_j = &(yy[1]); rll_i = ll_i; while ( rll_i != rtmp ) { register UChar rtmp2; ryy_j++; rtmp2 = rtmp; rtmp = *ryy_j; *ryy_j = rtmp2; }; yy[0] = rtmp; j = ryy_j - &(yy[0]); mtfv[wr] = j+1; wr++; s->mtfFreq[j+1]++; } } } if (zPend > 0) { zPend--; while (True) { if (zPend & 1) { mtfv[wr] = BZ_RUNB; wr++; s->mtfFreq[BZ_RUNB]++; } else { mtfv[wr] = BZ_RUNA; wr++; s->mtfFreq[BZ_RUNA]++; } if (zPend < 2) break; zPend = (zPend - 2) / 2; }; zPend = 0; } mtfv[wr] = EOB; wr++; s->mtfFreq[EOB]++; s->nMTF = wr; } /*---------------------------------------------------*/ #define BZ_LESSER_ICOST 0 #define BZ_GREATER_ICOST 15 static void sendMTFValues ( EState* s ) { Int32 v, t, i, j, gs, ge, totc, bt, bc, iter; Int32 nSelectors, alphaSize, minLen, maxLen, selCtr; Int32 nGroups, nBytes; /*-- UChar len [BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; is a global since the decoder also needs it. Int32 code[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; Int32 rfreq[BZ_N_GROUPS][BZ_MAX_ALPHA_SIZE]; are also globals only used in this proc. Made global to keep stack frame size small. --*/ UInt16 cost[BZ_N_GROUPS]; Int32 fave[BZ_N_GROUPS]; UInt16* mtfv = s->mtfv; if (s->verbosity >= 3) VPrintf3( " %d in block, %d after MTF & 1-2 coding, " "%d+2 syms in use\n", s->nblock, s->nMTF, s->nInUse ); alphaSize = s->nInUse+2; for (t = 0; t < BZ_N_GROUPS; t++) for (v = 0; v < alphaSize; v++) s->len[t][v] = BZ_GREATER_ICOST; /*--- Decide how many coding tables to use ---*/ AssertH ( s->nMTF > 0, 3001 ); if (s->nMTF < 200) nGroups = 2; else if (s->nMTF < 600) nGroups = 3; else if (s->nMTF < 1200) nGroups = 4; else if (s->nMTF < 2400) nGroups = 5; else nGroups = 6; /*--- Generate an initial set of coding tables ---*/ { Int32 nPart, remF, tFreq, aFreq; nPart = nGroups; remF = s->nMTF; gs = 0; while (nPart > 0) { tFreq = remF / nPart; ge = gs-1; aFreq = 0; while (aFreq < tFreq && ge < alphaSize-1) { ge++; aFreq += s->mtfFreq[ge]; } if (ge > gs && nPart != nGroups && nPart != 1 && ((nGroups-nPart) % 2 == 1)) { aFreq -= s->mtfFreq[ge]; ge--; } if (s->verbosity >= 3) VPrintf5( " initial group %d, [%d .. %d], " "has %d syms (%4.1f%%)\n", nPart, gs, ge, aFreq, (100.0 * (float)aFreq) / (float)(s->nMTF) ); for (v = 0; v < alphaSize; v++) if (v >= gs && v <= ge) s->len[nPart-1][v] = BZ_LESSER_ICOST; else s->len[nPart-1][v] = BZ_GREATER_ICOST; nPart--; gs = ge+1; remF -= aFreq; } } /*--- Iterate up to BZ_N_ITERS times to improve the tables. ---*/ for (iter = 0; iter < BZ_N_ITERS; iter++) { for (t = 0; t < nGroups; t++) fave[t] = 0; for (t = 0; t < nGroups; t++) for (v = 0; v < alphaSize; v++) s->rfreq[t][v] = 0; /*--- Set up an auxiliary length table which is used to fast-track the common case (nGroups == 6). ---*/ if (nGroups == 6) { for (v = 0; v < alphaSize; v++) { s->len_pack[v][0] = (s->len[1][v] << 16) | s->len[0][v]; s->len_pack[v][1] = (s->len[3][v] << 16) | s->len[2][v]; s->len_pack[v][2] = (s->len[5][v] << 16) | s->len[4][v]; } } nSelectors = 0; totc = 0; gs = 0; while (True) { /*--- Set group start & end marks. --*/ if (gs >= s->nMTF) break; ge = gs + BZ_G_SIZE - 1; if (ge >= s->nMTF) ge = s->nMTF-1; /*-- Calculate the cost of this group as coded by each of the coding tables. --*/ for (t = 0; t < nGroups; t++) cost[t] = 0; if (nGroups == 6 && 50 == ge-gs+1) { /*--- fast track the common case ---*/ register UInt32 cost01, cost23, cost45; register UInt16 icv; cost01 = cost23 = cost45 = 0; # define BZ_ITER(nn) \ icv = mtfv[gs+(nn)]; \ cost01 += s->len_pack[icv][0]; \ cost23 += s->len_pack[icv][1]; \ cost45 += s->len_pack[icv][2]; \ BZ_ITER(0); BZ_ITER(1); BZ_ITER(2); BZ_ITER(3); BZ_ITER(4); BZ_ITER(5); BZ_ITER(6); BZ_ITER(7); BZ_ITER(8); BZ_ITER(9); BZ_ITER(10); BZ_ITER(11); BZ_ITER(12); BZ_ITER(13); BZ_ITER(14); BZ_ITER(15); BZ_ITER(16); BZ_ITER(17); BZ_ITER(18); BZ_ITER(19); BZ_ITER(20); BZ_ITER(21); BZ_ITER(22); BZ_ITER(23); BZ_ITER(24); BZ_ITER(25); BZ_ITER(26); BZ_ITER(27); BZ_ITER(28); BZ_ITER(29); BZ_ITER(30); BZ_ITER(31); BZ_ITER(32); BZ_ITER(33); BZ_ITER(34); BZ_ITER(35); BZ_ITER(36); BZ_ITER(37); BZ_ITER(38); BZ_ITER(39); BZ_ITER(40); BZ_ITER(41); BZ_ITER(42); BZ_ITER(43); BZ_ITER(44); BZ_ITER(45); BZ_ITER(46); BZ_ITER(47); BZ_ITER(48); BZ_ITER(49); # undef BZ_ITER cost[0] = cost01 & 0xffff; cost[1] = cost01 >> 16; cost[2] = cost23 & 0xffff; cost[3] = cost23 >> 16; cost[4] = cost45 & 0xffff; cost[5] = cost45 >> 16; } else { /*--- slow version which correctly handles all situations ---*/ for (i = gs; i <= ge; i++) { UInt16 icv = mtfv[i]; for (t = 0; t < nGroups; t++) cost[t] += s->len[t][icv]; } } /*-- Find the coding table which is best for this group, and record its identity in the selector table. --*/ bc = 999999999; bt = -1; for (t = 0; t < nGroups; t++) if (cost[t] < bc) { bc = cost[t]; bt = t; }; totc += bc; fave[bt]++; s->selector[nSelectors] = bt; nSelectors++; /*-- Increment the symbol frequencies for the selected table. --*/ if (nGroups == 6 && 50 == ge-gs+1) { /*--- fast track the common case ---*/ # define BZ_ITUR(nn) s->rfreq[bt][ mtfv[gs+(nn)] ]++ BZ_ITUR(0); BZ_ITUR(1); BZ_ITUR(2); BZ_ITUR(3); BZ_ITUR(4); BZ_ITUR(5); BZ_ITUR(6); BZ_ITUR(7); BZ_ITUR(8); BZ_ITUR(9); BZ_ITUR(10); BZ_ITUR(11); BZ_ITUR(12); BZ_ITUR(13); BZ_ITUR(14); BZ_ITUR(15); BZ_ITUR(16); BZ_ITUR(17); BZ_ITUR(18); BZ_ITUR(19); BZ_ITUR(20); BZ_ITUR(21); BZ_ITUR(22); BZ_ITUR(23); BZ_ITUR(24); BZ_ITUR(25); BZ_ITUR(26); BZ_ITUR(27); BZ_ITUR(28); BZ_ITUR(29); BZ_ITUR(30); BZ_ITUR(31); BZ_ITUR(32); BZ_ITUR(33); BZ_ITUR(34); BZ_ITUR(35); BZ_ITUR(36); BZ_ITUR(37); BZ_ITUR(38); BZ_ITUR(39); BZ_ITUR(40); BZ_ITUR(41); BZ_ITUR(42); BZ_ITUR(43); BZ_ITUR(44); BZ_ITUR(45); BZ_ITUR(46); BZ_ITUR(47); BZ_ITUR(48); BZ_ITUR(49); # undef BZ_ITUR } else { /*--- slow version which correctly handles all situations ---*/ for (i = gs; i <= ge; i++) s->rfreq[bt][ mtfv[i] ]++; } gs = ge+1; } if (s->verbosity >= 3) { VPrintf2 ( " pass %d: size is %d, grp uses are ", iter+1, totc/8 ); for (t = 0; t < nGroups; t++) VPrintf1 ( "%d ", fave[t] ); VPrintf0 ( "\n" ); } /*-- Recompute the tables based on the accumulated frequencies. --*/ for (t = 0; t < nGroups; t++) BZ2_hbMakeCodeLengths ( &(s->len[t][0]), &(s->rfreq[t][0]), alphaSize, 20 ); } AssertH( nGroups < 8, 3002 ); AssertH( nSelectors < 32768 && nSelectors <= (2 + (900000 / BZ_G_SIZE)), 3003 ); /*--- Compute MTF values for the selectors. ---*/ { UChar pos[BZ_N_GROUPS], ll_i, tmp2, tmp; for (i = 0; i < nGroups; i++) pos[i] = i; for (i = 0; i < nSelectors; i++) { ll_i = s->selector[i]; j = 0; tmp = pos[j]; while ( ll_i != tmp ) { j++; tmp2 = tmp; tmp = pos[j]; pos[j] = tmp2; }; pos[0] = tmp; s->selectorMtf[i] = j; } }; /*--- Assign actual codes for the tables. --*/ for (t = 0; t < nGroups; t++) { minLen = 32; maxLen = 0; for (i = 0; i < alphaSize; i++) { if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; if (s->len[t][i] < minLen) minLen = s->len[t][i]; } AssertH ( !(maxLen > 20), 3004 ); AssertH ( !(minLen < 1), 3005 ); BZ2_hbAssignCodes ( &(s->code[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize ); } /*--- Transmit the mapping table. ---*/ { Bool inUse16[16]; for (i = 0; i < 16; i++) { inUse16[i] = False; for (j = 0; j < 16; j++) if (s->inUse[i * 16 + j]) inUse16[i] = True; } nBytes = s->numZ; for (i = 0; i < 16; i++) if (inUse16[i]) bsW(s,1,1); else bsW(s,1,0); for (i = 0; i < 16; i++) if (inUse16[i]) for (j = 0; j < 16; j++) { if (s->inUse[i * 16 + j]) bsW(s,1,1); else bsW(s,1,0); } if (s->verbosity >= 3) VPrintf1( " bytes: mapping %d, ", s->numZ-nBytes ); } /*--- Now the selectors. ---*/ nBytes = s->numZ; bsW ( s, 3, nGroups ); bsW ( s, 15, nSelectors ); for (i = 0; i < nSelectors; i++) { for (j = 0; j < s->selectorMtf[i]; j++) bsW(s,1,1); bsW(s,1,0); } if (s->verbosity >= 3) VPrintf1( "selectors %d, ", s->numZ-nBytes ); /*--- Now the coding tables. ---*/ nBytes = s->numZ; for (t = 0; t < nGroups; t++) { Int32 curr = s->len[t][0]; bsW ( s, 5, curr ); for (i = 0; i < alphaSize; i++) { while (curr < s->len[t][i]) { bsW(s,2,2); curr++; /* 10 */ }; while (curr > s->len[t][i]) { bsW(s,2,3); curr--; /* 11 */ }; bsW ( s, 1, 0 ); } } if (s->verbosity >= 3) VPrintf1 ( "code lengths %d, ", s->numZ-nBytes ); /*--- And finally, the block data proper ---*/ nBytes = s->numZ; selCtr = 0; gs = 0; while (True) { if (gs >= s->nMTF) break; ge = gs + BZ_G_SIZE - 1; if (ge >= s->nMTF) ge = s->nMTF-1; AssertH ( s->selector[selCtr] < nGroups, 3006 ); if (nGroups == 6 && 50 == ge-gs+1) { /*--- fast track the common case ---*/ UInt16 mtfv_i; UChar* s_len_sel_selCtr = &(s->len[s->selector[selCtr]][0]); Int32* s_code_sel_selCtr = &(s->code[s->selector[selCtr]][0]); # define BZ_ITAH(nn) \ mtfv_i = mtfv[gs+(nn)]; \ bsW ( s, \ s_len_sel_selCtr[mtfv_i], \ s_code_sel_selCtr[mtfv_i] ) BZ_ITAH(0); BZ_ITAH(1); BZ_ITAH(2); BZ_ITAH(3); BZ_ITAH(4); BZ_ITAH(5); BZ_ITAH(6); BZ_ITAH(7); BZ_ITAH(8); BZ_ITAH(9); BZ_ITAH(10); BZ_ITAH(11); BZ_ITAH(12); BZ_ITAH(13); BZ_ITAH(14); BZ_ITAH(15); BZ_ITAH(16); BZ_ITAH(17); BZ_ITAH(18); BZ_ITAH(19); BZ_ITAH(20); BZ_ITAH(21); BZ_ITAH(22); BZ_ITAH(23); BZ_ITAH(24); BZ_ITAH(25); BZ_ITAH(26); BZ_ITAH(27); BZ_ITAH(28); BZ_ITAH(29); BZ_ITAH(30); BZ_ITAH(31); BZ_ITAH(32); BZ_ITAH(33); BZ_ITAH(34); BZ_ITAH(35); BZ_ITAH(36); BZ_ITAH(37); BZ_ITAH(38); BZ_ITAH(39); BZ_ITAH(40); BZ_ITAH(41); BZ_ITAH(42); BZ_ITAH(43); BZ_ITAH(44); BZ_ITAH(45); BZ_ITAH(46); BZ_ITAH(47); BZ_ITAH(48); BZ_ITAH(49); # undef BZ_ITAH } else { /*--- slow version which correctly handles all situations ---*/ for (i = gs; i <= ge; i++) { bsW ( s, s->len [s->selector[selCtr]] [mtfv[i]], s->code [s->selector[selCtr]] [mtfv[i]] ); } } gs = ge+1; selCtr++; } AssertH( selCtr == nSelectors, 3007 ); if (s->verbosity >= 3) VPrintf1( "codes %d\n", s->numZ-nBytes ); } /*---------------------------------------------------*/ void BZ2_compressBlock ( EState* s, Bool is_last_block ) { if (s->nblock > 0) { BZ_FINALISE_CRC ( s->blockCRC ); s->combinedCRC = (s->combinedCRC << 1) | (s->combinedCRC >> 31); s->combinedCRC ^= s->blockCRC; if (s->blockNo > 1) s->numZ = 0; if (s->verbosity >= 2) VPrintf4( " block %d: crc = 0x%8x, " "combined CRC = 0x%8x, size = %d\n", s->blockNo, s->blockCRC, s->combinedCRC, s->nblock ); BZ2_blockSort ( s ); } s->zbits = (UChar*) (&((UChar*)s->arr2)[s->nblock]); /*-- If this is the first block, create the stream header. --*/ if (s->blockNo == 1) { BZ2_bsInitWrite ( s ); bsPutUChar ( s, BZ_HDR_B ); bsPutUChar ( s, BZ_HDR_Z ); bsPutUChar ( s, BZ_HDR_h ); bsPutUChar ( s, (UChar)(BZ_HDR_0 + s->blockSize100k) ); } if (s->nblock > 0) { bsPutUChar ( s, 0x31 ); bsPutUChar ( s, 0x41 ); bsPutUChar ( s, 0x59 ); bsPutUChar ( s, 0x26 ); bsPutUChar ( s, 0x53 ); bsPutUChar ( s, 0x59 ); /*-- Now the block's CRC, so it is in a known place. --*/ bsPutUInt32 ( s, s->blockCRC ); /*-- Now a single bit indicating (non-)randomisation. As of version 0.9.5, we use a better sorting algorithm which makes randomisation unnecessary. So always set the randomised bit to 'no'. Of course, the decoder still needs to be able to handle randomised blocks so as to maintain backwards compatibility with older versions of bzip2. --*/ bsW(s,1,0); bsW ( s, 24, s->origPtr ); generateMTFValues ( s ); sendMTFValues ( s ); } /*-- If this is the last block, add the stream trailer. --*/ if (is_last_block) { bsPutUChar ( s, 0x17 ); bsPutUChar ( s, 0x72 ); bsPutUChar ( s, 0x45 ); bsPutUChar ( s, 0x38 ); bsPutUChar ( s, 0x50 ); bsPutUChar ( s, 0x90 ); bsPutUInt32 ( s, s->combinedCRC ); if (s->verbosity >= 2) VPrintf1( " final combined CRC = 0x%x\n ", s->combinedCRC ); bsFinishWrite ( s ); } } /*-------------------------------------------------------------*/ /*--- end compress.c ---*/ /*-------------------------------------------------------------*/ --- NEW FILE: crctable.c --- /*-------------------------------------------------------------*/ /*--- Table for doing CRCs ---*/ /*--- crctable.c ---*/ /*-------------------------------------------------------------*/ /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. jseward at acm.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: Mike Burrows David Wheeler Peter Fenwick Alistair Moffat Radford Neal Ian H. Witten Robert Sedgewick Jon L. Bentley For more information on these sources, see the manual. --*/ #include "bzlib_private.h" /*-- I think this is an implementation of the AUTODIN-II, Ethernet & FDDI 32-bit CRC standard. Vaguely derived from code by Rob Warnock, in Section 51 of the comp.compression FAQ. --*/ UInt32 BZ2_crc32Table[256] = { /*-- Ugly, innit? --*/ 0x00000000L, 0x04c11db7L, 0x09823b6eL, 0x0d4326d9L, 0x130476dcL, 0x17c56b6bL, 0x1a864db2L, 0x1e475005L, 0x2608edb8L, 0x22c9f00fL, 0x2f8ad6d6L, 0x2b4bcb61L, 0x350c9b64L, 0x31cd86d3L, 0x3c8ea00aL, 0x384fbdbdL, 0x4c11db70L, 0x48d0c6c7L, 0x4593e01eL, 0x4152fda9L, 0x5f15adacL, 0x5bd4b01bL, 0x569796c2L, 0x52568b75L, 0x6a1936c8L, 0x6ed82b7fL, 0x639b0da6L, 0x675a1011L, 0x791d4014L, 0x7ddc5da3L, 0x709f7b7aL, 0x745e66cdL, 0x9823b6e0L, 0x9ce2ab57L, 0x91a18d8eL, 0x95609039L, 0x8b27c03cL, 0x8fe6dd8bL, 0x82a5fb52L, 0x8664e6e5L, 0xbe2b5b58L, 0xbaea46efL, 0xb7a96036L, 0xb3687d81L, 0xad2f2d84L, 0xa9ee3033L, 0xa4ad16eaL, 0xa06c0b5dL, 0xd4326d90L, 0xd0f37027L, 0xddb056feL, 0xd9714b49L, 0xc7361b4cL, 0xc3f706fbL, 0xceb42022L, 0xca753d95L, 0xf23a8028L, 0xf6fb9d9fL, 0xfbb8bb46L, 0xff79a6f1L, 0xe13ef6f4L, 0xe5ffeb43L, 0xe8bccd9aL, 0xec7dd02dL, 0x34867077L, 0x30476dc0L, 0x3d044b19L, 0x39c556aeL, 0x278206abL, 0x23431b1cL, 0x2e003dc5L, 0x2ac12072L, 0x128e9dcfL, 0x164f8078L, 0x1b0ca6a1L, 0x1fcdbb16L, 0x018aeb13L, 0x054bf6a4L, 0x0808d07dL, 0x0cc9cdcaL, 0x7897ab07L, 0x7c56b6b0L, 0x71159069L, 0x75d48ddeL, 0x6b93dddbL, 0x6f52c06cL, 0x6211e6b5L, 0x66d0fb02L, 0x5e9f46bfL, 0x5a5e5b08L, 0x571d7dd1L, 0x53dc6066L, 0x4d9b3063L, 0x495a2dd4L, 0x44190b0dL, 0x40d816baL, 0xaca5c697L, 0xa864db20L, 0xa527fdf9L, 0xa1e6e04eL, 0xbfa1b04bL, 0xbb60adfcL, 0xb6238b25L, 0xb2e29692L, 0x8aad2b2fL, 0x8e6c3698L, 0x832f1041L, 0x87ee0df6L, 0x99a95df3L, 0x9d684044L, 0x902b669dL, 0x94ea7b2aL, 0xe0b41de7L, 0xe4750050L, 0xe9362689L, 0xedf73b3eL, 0xf3b06b3bL, 0xf771768cL, 0xfa325055L, 0xfef34de2L, 0xc6bcf05fL, 0xc27dede8L, 0xcf3ecb31L, 0xcbffd686L, 0xd5b88683L, 0xd1799b34L, 0xdc3abdedL, 0xd8fba05aL, 0x690ce0eeL, 0x6dcdfd59L, 0x608edb80L, 0x644fc637L, 0x7a089632L, 0x7ec98b85L, 0x738aad5cL, 0x774bb0ebL, 0x4f040d56L, 0x4bc510e1L, 0x46863638L, 0x42472b8fL, 0x5c007b8aL, 0x58c1663dL, 0x558240e4L, 0x51435d53L, 0x251d3b9eL, 0x21dc2629L, 0x2c9f00f0L, 0x285e1d47L, 0x36194d42L, 0x32d850f5L, 0x3f9b762cL, 0x3b5a6b9bL, 0x0315d626L, 0x07d4cb91L, 0x0a97ed48L, 0x0e56f0ffL, 0x1011a0faL, 0x14d0bd4dL, 0x19939b94L, 0x1d528623L, 0xf12f560eL, 0xf5ee4bb9L, 0xf8ad6d60L, 0xfc6c70d7L, 0xe22b20d2L, 0xe6ea3d65L, 0xeba91bbcL, 0xef68060bL, 0xd727bbb6L, 0xd3e6a601L, 0xdea580d8L, 0xda649d6fL, 0xc423cd6aL, 0xc0e2d0ddL, 0xcda1f604L, 0xc960ebb3L, 0xbd3e8d7eL, 0xb9ff90c9L, 0xb4bcb610L, 0xb07daba7L, 0xae3afba2L, 0xaafbe615L, 0xa7b8c0ccL, 0xa379dd7bL, 0x9b3660c6L, 0x9ff77d71L, 0x92b45ba8L, 0x9675461fL, 0x8832161aL, 0x8cf30badL, 0x81b02d74L, 0x857130c3L, 0x5d8a9099L, 0x594b8d2eL, 0x5408abf7L, 0x50c9b640L, 0x4e8ee645L, 0x4a4ffbf2L, 0x470cdd2bL, 0x43cdc09cL, 0x7b827d21L, 0x7f436096L, 0x7200464fL, 0x76c15bf8L, 0x68860bfdL, 0x6c47164aL, 0x61043093L, 0x65c52d24L, 0x119b4be9L, 0x155a565eL, 0x18197087L, 0x1cd86d30L, 0x029f3d35L, 0x065e2082L, 0x0b1d065bL, 0x0fdc1becL, 0x3793a651L, 0x3352bbe6L, 0x3e119d3fL, 0x3ad08088L, 0x2497d08dL, 0x2056cd3aL, 0x2d15ebe3L, 0x29d4f654L, 0xc5a92679L, 0xc1683bceL, 0xcc2b1d17L, 0xc8ea00a0L, 0xd6ad50a5L, 0xd26c4d12L, 0xdf2f6bcbL, 0xdbee767cL, 0xe3a1cbc1L, 0xe760d676L, 0xea23f0afL, 0xeee2ed18L, 0xf0a5bd1dL, 0xf464a0aaL, 0xf9278673L, 0xfde69bc4L, 0x89b8fd09L, 0x8d79e0beL, 0x803ac667L, 0x84fbdbd0L, 0x9abc8bd5L, 0x9e7d9662L, 0x933eb0bbL, 0x97ffad0cL, 0xafb010b1L, 0xab710d06L, 0xa6322bdfL, 0xa2f33668L, 0xbcb4666dL, 0xb8757bdaL, 0xb5365d03L, 0xb1f740b4L }; /*-------------------------------------------------------------*/ /*--- end crctable.c ---*/ /*-------------------------------------------------------------*/ --- NEW FILE: decompress.c --- /*-------------------------------------------------------------*/ /*--- Decompression machinery ---*/ /*--- decompress.c ---*/ /*-------------------------------------------------------------*/ /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. jseward at acm.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: Mike Burrows David Wheeler Peter Fenwick Alistair Moffat Radford Neal Ian H. Witten Robert Sedgewick Jon L. Bentley For more information on these sources, see the manual. --*/ #include "bzlib_private.h" /*---------------------------------------------------*/ static void makeMaps_d ( DState* s ) { Int32 i; s->nInUse = 0; for (i = 0; i < 256; i++) if (s->inUse[i]) { s->seqToUnseq[s->nInUse] = i; s->nInUse++; } } /*---------------------------------------------------*/ #define RETURN(rrr) \ { retVal = rrr; goto save_state_and_return; }; #define GET_BITS(lll,vvv,nnn) \ case lll: s->state = lll; \ while (True) { \ if (s->bsLive >= nnn) { \ UInt32 v; \ v = (s->bsBuff >> \ (s->bsLive-nnn)) & ((1 << nnn)-1); \ s->bsLive -= nnn; \ vvv = v; \ break; \ } \ if (s->strm->avail_in == 0) RETURN(BZ_OK); \ s->bsBuff \ = (s->bsBuff << 8) | \ ((UInt32) \ (*((UChar*)(s->strm->next_in)))); \ s->bsLive += 8; \ s->strm->next_in++; \ s->strm->avail_in--; \ s->strm->total_in_lo32++; \ if (s->strm->total_in_lo32 == 0) \ s->strm->total_in_hi32++; \ } #define GET_UCHAR(lll,uuu) \ GET_BITS(lll,uuu,8) #define GET_BIT(lll,uuu) \ GET_BITS(lll,uuu,1) /*---------------------------------------------------*/ #define GET_MTF_VAL(label1,label2,lval) \ { \ if (groupPos == 0) { \ groupNo++; \ if (groupNo >= nSelectors) \ RETURN(BZ_DATA_ERROR); \ groupPos = BZ_G_SIZE; \ gSel = s->selector[groupNo]; \ gMinlen = s->minLens[gSel]; \ gLimit = &(s->limit[gSel][0]); \ gPerm = &(s->perm[gSel][0]); \ gBase = &(s->base[gSel][0]); \ } \ groupPos--; \ zn = gMinlen; \ GET_BITS(label1, zvec, zn); \ while (1) { \ if (zn > 20 /* the longest code */) \ RETURN(BZ_DATA_ERROR); \ if (zvec <= gLimit[zn]) break; \ zn++; \ GET_BIT(label2, zj); \ zvec = (zvec << 1) | zj; \ }; \ if (zvec - gBase[zn] < 0 \ || zvec - gBase[zn] >= BZ_MAX_ALPHA_SIZE) \ RETURN(BZ_DATA_ERROR); \ lval = gPerm[zvec - gBase[zn]]; \ } /*---------------------------------------------------*/ Int32 BZ2_decompress ( DState* s ) { UChar uc; Int32 retVal; Int32 minLen, maxLen; bz_stream* strm = s->strm; /* stuff that needs to be saved/restored */ Int32 i; Int32 j; Int32 t; Int32 alphaSize; Int32 nGroups; Int32 nSelectors; Int32 EOB; Int32 groupNo; Int32 groupPos; Int32 nextSym; Int32 nblockMAX; Int32 nblock; Int32 es; Int32 N; Int32 curr; Int32 zt; Int32 zn; Int32 zvec; Int32 zj; Int32 gSel; Int32 gMinlen; Int32* gLimit; Int32* gBase; Int32* gPerm; if (s->state == BZ_X_MAGIC_1) { /*initialise the save area*/ s->save_i = 0; s->save_j = 0; s->save_t = 0; s->save_alphaSize = 0; s->save_nGroups = 0; s->save_nSelectors = 0; s->save_EOB = 0; s->save_groupNo = 0; s->save_groupPos = 0; s->save_nextSym = 0; s->save_nblockMAX = 0; s->save_nblock = 0; s->save_es = 0; s->save_N = 0; s->save_curr = 0; s->save_zt = 0; s->save_zn = 0; s->save_zvec = 0; s->save_zj = 0; s->save_gSel = 0; s->save_gMinlen = 0; s->save_gLimit = NULL; s->save_gBase = NULL; s->save_gPerm = NULL; } /*restore from the save area*/ i = s->save_i; j = s->save_j; t = s->save_t; alphaSize = s->save_alphaSize; nGroups = s->save_nGroups; nSelectors = s->save_nSelectors; EOB = s->save_EOB; groupNo = s->save_groupNo; groupPos = s->save_groupPos; nextSym = s->save_nextSym; nblockMAX = s->save_nblockMAX; nblock = s->save_nblock; es = s->save_es; N = s->save_N; curr = s->save_curr; zt = s->save_zt; zn = s->save_zn; zvec = s->save_zvec; zj = s->save_zj; gSel = s->save_gSel; gMinlen = s->save_gMinlen; gLimit = s->save_gLimit; gBase = s->save_gBase; gPerm = s->save_gPerm; retVal = BZ_OK; switch (s->state) { GET_UCHAR(BZ_X_MAGIC_1, uc); if (uc != BZ_HDR_B) RETURN(BZ_DATA_ERROR_MAGIC); GET_UCHAR(BZ_X_MAGIC_2, uc); if (uc != BZ_HDR_Z) RETURN(BZ_DATA_ERROR_MAGIC); GET_UCHAR(BZ_X_MAGIC_3, uc) if (uc != BZ_HDR_h) RETURN(BZ_DATA_ERROR_MAGIC); GET_BITS(BZ_X_MAGIC_4, s->blockSize100k, 8) if (s->blockSize100k < (BZ_HDR_0 + 1) || s->blockSize100k > (BZ_HDR_0 + 9)) RETURN(BZ_DATA_ERROR_MAGIC); s->blockSize100k -= BZ_HDR_0; if (s->smallDecompress) { s->ll16 = BZALLOC( s->blockSize100k * 100000 * sizeof(UInt16) ); s->ll4 = BZALLOC( ((1 + s->blockSize100k * 100000) >> 1) * sizeof(UChar) ); if (s->ll16 == NULL || s->ll4 == NULL) RETURN(BZ_MEM_ERROR); } else { s->tt = BZALLOC( s->blockSize100k * 100000 * sizeof(Int32) ); if (s->tt == NULL) RETURN(BZ_MEM_ERROR); } GET_UCHAR(BZ_X_BLKHDR_1, uc); if (uc == 0x17) goto endhdr_2; if (uc != 0x31) RETURN(BZ_DATA_ERROR); GET_UCHAR(BZ_X_BLKHDR_2, uc); if (uc != 0x41) RETURN(BZ_DATA_ERROR); GET_UCHAR(BZ_X_BLKHDR_3, uc); if (uc != 0x59) RETURN(BZ_DATA_ERROR); GET_UCHAR(BZ_X_BLKHDR_4, uc); if (uc != 0x26) RETURN(BZ_DATA_ERROR); GET_UCHAR(BZ_X_BLKHDR_5, uc); if (uc != 0x53) RETURN(BZ_DATA_ERROR); GET_UCHAR(BZ_X_BLKHDR_6, uc); if (uc != 0x59) RETURN(BZ_DATA_ERROR); s->currBlockNo++; if (s->verbosity >= 2) VPrintf1 ( "\n [%d: huff+mtf ", s->currBlockNo ); s->storedBlockCRC = 0; GET_UCHAR(BZ_X_BCRC_1, uc); s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); GET_UCHAR(BZ_X_BCRC_2, uc); s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); GET_UCHAR(BZ_X_BCRC_3, uc); s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); GET_UCHAR(BZ_X_BCRC_4, uc); s->storedBlockCRC = (s->storedBlockCRC << 8) | ((UInt32)uc); GET_BITS(BZ_X_RANDBIT, s->blockRandomised, 1); s->origPtr = 0; GET_UCHAR(BZ_X_ORIGPTR_1, uc); s->origPtr = (s->origPtr << 8) | ((Int32)uc); GET_UCHAR(BZ_X_ORIGPTR_2, uc); s->origPtr = (s->origPtr << 8) | ((Int32)uc); GET_UCHAR(BZ_X_ORIGPTR_3, uc); s->origPtr = (s->origPtr << 8) | ((Int32)uc); if (s->origPtr < 0) RETURN(BZ_DATA_ERROR); if (s->origPtr > 10 + 100000*s->blockSize100k) RETURN(BZ_DATA_ERROR); /*--- Receive the mapping table ---*/ for (i = 0; i < 16; i++) { GET_BIT(BZ_X_MAPPING_1, uc); if (uc == 1) s->inUse16[i] = True; else s->inUse16[i] = False; } for (i = 0; i < 256; i++) s->inUse[i] = False; for (i = 0; i < 16; i++) if (s->inUse16[i]) for (j = 0; j < 16; j++) { GET_BIT(BZ_X_MAPPING_2, uc); if (uc == 1) s->inUse[i * 16 + j] = True; } makeMaps_d ( s ); if (s->nInUse == 0) RETURN(BZ_DATA_ERROR); alphaSize = s->nInUse+2; /*--- Now the selectors ---*/ GET_BITS(BZ_X_SELECTOR_1, nGroups, 3); if (nGroups < 2 || nGroups > 6) RETURN(BZ_DATA_ERROR); GET_BITS(BZ_X_SELECTOR_2, nSelectors, 15); if (nSelectors < 1) RETURN(BZ_DATA_ERROR); for (i = 0; i < nSelectors; i++) { j = 0; while (True) { GET_BIT(BZ_X_SELECTOR_3, uc); if (uc == 0) break; j++; if (j >= nGroups) RETURN(BZ_DATA_ERROR); } s->selectorMtf[i] = j; } /*--- Undo the MTF values for the selectors. ---*/ { UChar pos[BZ_N_GROUPS], tmp, v; for (v = 0; v < nGroups; v++) pos[v] = v; for (i = 0; i < nSelectors; i++) { v = s->selectorMtf[i]; tmp = pos[v]; while (v > 0) { pos[v] = pos[v-1]; v--; } pos[0] = tmp; s->selector[i] = tmp; } } /*--- Now the coding tables ---*/ for (t = 0; t < nGroups; t++) { GET_BITS(BZ_X_CODING_1, curr, 5); for (i = 0; i < alphaSize; i++) { while (True) { if (curr < 1 || curr > 20) RETURN(BZ_DATA_ERROR); GET_BIT(BZ_X_CODING_2, uc); if (uc == 0) break; GET_BIT(BZ_X_CODING_3, uc); if (uc == 0) curr++; else curr--; } s->len[t][i] = curr; } } /*--- Create the Huffman decoding tables ---*/ for (t = 0; t < nGroups; t++) { minLen = 32; maxLen = 0; for (i = 0; i < alphaSize; i++) { if (s->len[t][i] > maxLen) maxLen = s->len[t][i]; if (s->len[t][i] < minLen) minLen = s->len[t][i]; } BZ2_hbCreateDecodeTables ( &(s->limit[t][0]), &(s->base[t][0]), &(s->perm[t][0]), &(s->len[t][0]), minLen, maxLen, alphaSize ); s->minLens[t] = minLen; } /*--- Now the MTF values ---*/ EOB = s->nInUse+1; nblockMAX = 100000 * s->blockSize100k; groupNo = -1; groupPos = 0; for (i = 0; i <= 255; i++) s->unzftab[i] = 0; /*-- MTF init --*/ { Int32 ii, jj, kk; kk = MTFA_SIZE-1; for (ii = 256 / MTFL_SIZE - 1; ii >= 0; ii--) { for (jj = MTFL_SIZE-1; jj >= 0; jj--) { s->mtfa[kk] = (UChar)(ii * MTFL_SIZE + jj); kk--; } s->mtfbase[ii] = kk + 1; } } /*-- end MTF init --*/ nblock = 0; GET_MTF_VAL(BZ_X_MTF_1, BZ_X_MTF_2, nextSym); while (True) { if (nextSym == EOB) break; if (nextSym == BZ_RUNA || nextSym == BZ_RUNB) { es = -1; N = 1; do { if (nextSym == BZ_RUNA) es = es + (0+1) * N; else if (nextSym == BZ_RUNB) es = es + (1+1) * N; N = N * 2; GET_MTF_VAL(BZ_X_MTF_3, BZ_X_MTF_4, nextSym); } while (nextSym == BZ_RUNA || nextSym == BZ_RUNB); es++; uc = s->seqToUnseq[ s->mtfa[s->mtfbase[0]] ]; s->unzftab[uc] += es; if (s->smallDecompress) while (es > 0) { if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); s->ll16[nblock] = (UInt16)uc; nblock++; es--; } else while (es > 0) { if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); s->tt[nblock] = (UInt32)uc; nblock++; es--; }; continue; } else { if (nblock >= nblockMAX) RETURN(BZ_DATA_ERROR); /*-- uc = MTF ( nextSym-1 ) --*/ { Int32 ii, jj, kk, pp, lno, off; UInt32 nn; nn = (UInt32)(nextSym - 1); if (nn < MTFL_SIZE) { /* avoid general-case expense */ pp = s->mtfbase[0]; uc = s->mtfa[pp+nn]; while (nn > 3) { Int32 z = pp+nn; s->mtfa[(z) ] = s->mtfa[(z)-1]; s->mtfa[(z)-1] = s->mtfa[(z)-2]; s->mtfa[(z)-2] = s->mtfa[(z)-3]; s->mtfa[(z)-3] = s->mtfa[(z)-4]; nn -= 4; } while (nn > 0) { s->mtfa[(pp+nn)] = s->mtfa[(pp+nn)-1]; nn--; }; s->mtfa[pp] = uc; } else { /* general case */ lno = nn / MTFL_SIZE; off = nn % MTFL_SIZE; pp = s->mtfbase[lno] + off; uc = s->mtfa[pp]; while (pp > s->mtfbase[lno]) { s->mtfa[pp] = s->mtfa[pp-1]; pp--; }; s->mtfbase[lno]++; while (lno > 0) { s->mtfbase[lno]--; s->mtfa[s->mtfbase[lno]] = s->mtfa[s->mtfbase[lno-1] + MTFL_SIZE - 1]; lno--; } s->mtfbase[0]--; s->mtfa[s->mtfbase[0]] = uc; if (s->mtfbase[0] == 0) { kk = MTFA_SIZE-1; for (ii = 256 / MTFL_SIZE-1; ii >= 0; ii--) { for (jj = MTFL_SIZE-1; jj >= 0; jj--) { s->mtfa[kk] = s->mtfa[s->mtfbase[ii] + jj]; kk--; } s->mtfbase[ii] = kk + 1; } } } } /*-- end uc = MTF ( nextSym-1 ) --*/ s->unzftab[s->seqToUnseq[uc]]++; if (s->smallDecompress) s->ll16[nblock] = (UInt16)(s->seqToUnseq[uc]); else s->tt[nblock] = (UInt32)(s->seqToUnseq[uc]); nblock++; GET_MTF_VAL(BZ_X_MTF_5, BZ_X_MTF_6, nextSym); continue; } } /* Now we know what nblock is, we can do a better sanity check on s->origPtr. */ if (s->origPtr < 0 || s->origPtr >= nblock) RETURN(BZ_DATA_ERROR); s->state_out_len = 0; s->state_out_ch = 0; BZ_INITIALISE_CRC ( s->calculatedBlockCRC ); s->state = BZ_X_OUTPUT; if (s->verbosity >= 2) VPrintf0 ( "rt+rld" ); /*-- Set up cftab to facilitate generation of T^(-1) --*/ s->cftab[0] = 0; for (i = 1; i <= 256; i++) s->cftab[i] = s->unzftab[i-1]; for (i = 1; i <= 256; i++) s->cftab[i] += s->cftab[i-1]; if (s->smallDecompress) { /*-- Make a copy of cftab, used in generation of T --*/ for (i = 0; i <= 256; i++) s->cftabCopy[i] = s->cftab[i]; /*-- compute the T vector --*/ for (i = 0; i < nblock; i++) { uc = (UChar)(s->ll16[i]); SET_LL(i, s->cftabCopy[uc]); s->cftabCopy[uc]++; } /*-- Compute T^(-1) by pointer reversal on T --*/ i = s->origPtr; j = GET_LL(i); do { Int32 tmp = GET_LL(j); SET_LL(j, i); i = j; j = tmp; } while (i != s->origPtr); s->tPos = s->origPtr; s->nblock_used = 0; if (s->blockRandomised) { BZ_RAND_INIT_MASK; BZ_GET_SMALL(s->k0); s->nblock_used++; BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; } else { BZ_GET_SMALL(s->k0); s->nblock_used++; } } else { /*-- compute the T^(-1) vector --*/ for (i = 0; i < nblock; i++) { uc = (UChar)(s->tt[i] & 0xff); s->tt[s->cftab[uc]] |= (i << 8); s->cftab[uc]++; } s->tPos = s->tt[s->origPtr] >> 8; s->nblock_used = 0; if (s->blockRandomised) { BZ_RAND_INIT_MASK; BZ_GET_FAST(s->k0); s->nblock_used++; BZ_RAND_UPD_MASK; s->k0 ^= BZ_RAND_MASK; } else { BZ_GET_FAST(s->k0); s->nblock_used++; } } RETURN(BZ_OK); endhdr_2: GET_UCHAR(BZ_X_ENDHDR_2, uc); if (uc != 0x72) RETURN(BZ_DATA_ERROR); GET_UCHAR(BZ_X_ENDHDR_3, uc); if (uc != 0x45) RETURN(BZ_DATA_ERROR); GET_UCHAR(BZ_X_ENDHDR_4, uc); if (uc != 0x38) RETURN(BZ_DATA_ERROR); GET_UCHAR(BZ_X_ENDHDR_5, uc); if (uc != 0x50) RETURN(BZ_DATA_ERROR); GET_UCHAR(BZ_X_ENDHDR_6, uc); if (uc != 0x90) RETURN(BZ_DATA_ERROR); s->storedCombinedCRC = 0; GET_UCHAR(BZ_X_CCRC_1, uc); s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); GET_UCHAR(BZ_X_CCRC_2, uc); s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); GET_UCHAR(BZ_X_CCRC_3, uc); s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); GET_UCHAR(BZ_X_CCRC_4, uc); s->storedCombinedCRC = (s->storedCombinedCRC << 8) | ((UInt32)uc); s->state = BZ_X_IDLE; RETURN(BZ_STREAM_END); default: AssertH ( False, 4001 ); } AssertH ( False, 4002 ); save_state_and_return: s->save_i = i; s->save_j = j; s->save_t = t; s->save_alphaSize = alphaSize; s->save_nGroups = nGroups; s->save_nSelectors = nSelectors; s->save_EOB = EOB; s->save_groupNo = groupNo; s->save_groupPos = groupPos; s->save_nextSym = nextSym; s->save_nblockMAX = nblockMAX; s->save_nblock = nblock; s->save_es = es; s->save_N = N; s->save_curr = curr; s->save_zt = zt; s->save_zn = zn; s->save_zvec = zvec; s->save_zj = zj; s->save_gSel = gSel; s->save_gMinlen = gMinlen; s->save_gLimit = gLimit; s->save_gBase = gBase; s->save_gPerm = gPerm; return retVal; } /*-------------------------------------------------------------*/ /*--- end decompress.c ---*/ /*-------------------------------------------------------------*/ --- NEW FILE: dlltest.c --- /* minibz2 libbz2.dll test program. by Yoshioka Tsuneo(QWF00133 at nifty.ne.jp/tsuneo-y at is.aist-nara.ac.jp) This file is Public Domain. welcome any email to me. usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename] */ #define BZ_IMPORT #include #include #include "bzlib.h" #ifdef _WIN32 #include #endif #ifdef _WIN32 #define BZ2_LIBNAME "libbz2-1.0.2.DLL" #include static int BZ2DLLLoaded = 0; static HINSTANCE BZ2DLLhLib; int BZ2DLLLoadLibrary(void) { HINSTANCE hLib; if(BZ2DLLLoaded==1){return 0;} hLib=LoadLibrary(BZ2_LIBNAME); if(hLib == NULL){ fprintf(stderr,"Can't load %s\n",BZ2_LIBNAME); return -1; } BZ2_bzlibVersion=GetProcAddress(hLib,"BZ2_bzlibVersion"); BZ2_bzopen=GetProcAddress(hLib,"BZ2_bzopen"); BZ2_bzdopen=GetProcAddress(hLib,"BZ2_bzdopen"); BZ2_bzread=GetProcAddress(hLib,"BZ2_bzread"); BZ2_bzwrite=GetProcAddress(hLib,"BZ2_bzwrite"); BZ2_bzflush=GetProcAddress(hLib,"BZ2_bzflush"); BZ2_bzclose=GetProcAddress(hLib,"BZ2_bzclose"); BZ2_bzerror=GetProcAddress(hLib,"BZ2_bzerror"); if (!BZ2_bzlibVersion || !BZ2_bzopen || !BZ2_bzdopen || !BZ2_bzread || !BZ2_bzwrite || !BZ2_bzflush || !BZ2_bzclose || !BZ2_bzerror) { fprintf(stderr,"GetProcAddress failed.\n"); return -1; } BZ2DLLLoaded=1; BZ2DLLhLib=hLib; return 0; } int BZ2DLLFreeLibrary(void) { if(BZ2DLLLoaded==0){return 0;} FreeLibrary(BZ2DLLhLib); BZ2DLLLoaded=0; } #endif /* WIN32 */ void usage(void) { puts("usage: minibz2 [-d] [-{1,2,..9}] [[srcfilename] destfilename]"); } int main(int argc,char *argv[]) { int decompress = 0; int level = 9; char *fn_r = NULL; char *fn_w = NULL; #ifdef _WIN32 if(BZ2DLLLoadLibrary()<0){ fprintf(stderr,"Loading of %s failed. Giving up.\n", BZ2_LIBNAME); exit(1); } printf("Loading of %s succeeded. Library version is %s.\n", BZ2_LIBNAME, BZ2_bzlibVersion() ); #endif while(++argv,--argc){ if(**argv =='-' || **argv=='/'){ char *p; for(p=*argv+1;*p;p++){ if(*p=='d'){ decompress = 1; }else if('1'<=*p && *p<='9'){ level = *p - '0'; }else{ usage(); exit(1); } } }else{ break; } } if(argc>=1){ fn_r = *argv; argc--;argv++; }else{ fn_r = NULL; } if(argc>=1){ fn_w = *argv; argc--;argv++; }else{ fn_w = NULL; } { int len; char buff[0x1000]; char mode[10]; if(decompress){ BZFILE *BZ2fp_r = NULL; FILE *fp_w = NULL; if(fn_w){ if((fp_w = fopen(fn_w,"wb"))==NULL){ printf("can't open [%s]\n",fn_w); perror("reason:"); exit(1); } }else{ fp_w = stdout; } if((fn_r == NULL && (BZ2fp_r = BZ2_bzdopen(fileno(stdin),"rb"))==NULL) || (fn_r != NULL && (BZ2fp_r = BZ2_bzopen(fn_r,"rb"))==NULL)){ printf("can't bz2openstream\n"); exit(1); } while((len=BZ2_bzread(BZ2fp_r,buff,0x1000))>0){ fwrite(buff,1,len,fp_w); } BZ2_bzclose(BZ2fp_r); if(fp_w != stdout) fclose(fp_w); }else{ BZFILE *BZ2fp_w = NULL; FILE *fp_r = NULL; if(fn_r){ if((fp_r = fopen(fn_r,"rb"))==NULL){ printf("can't open [%s]\n",fn_r); perror("reason:"); exit(1); } }else{ fp_r = stdin; } mode[0]='w'; mode[1] = '0' + level; mode[2] = '\0'; if((fn_w == NULL && (BZ2fp_w = BZ2_bzdopen(fileno(stdout),mode))==NULL) || (fn_w !=NULL && (BZ2fp_w = BZ2_bzopen(fn_w,mode))==NULL)){ printf("can't bz2openstream\n"); exit(1); } while((len=fread(buff,1,0x1000,fp_r))>0){ BZ2_bzwrite(BZ2fp_w,buff,len); } BZ2_bzclose(BZ2fp_w); if(fp_r!=stdin)fclose(fp_r); } } #ifdef _WIN32 BZ2DLLFreeLibrary(); #endif return 0; } --- NEW FILE: dlltest.dsp --- # Microsoft Developer Studio Project File - Name="dlltest" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 5.00 # ** ???W???????????????? ** # TARGTYPE "Win32 (x86) Console Application" 0x0103 CFG=dlltest - Win32 Debug !MESSAGE ???????L??????????????????????????B ??????????????????????????????? NMAKE ???g?p?????????????B !MESSAGE [????????????????] ????????g?p???????s???????????? !MESSAGE !MESSAGE NMAKE /f "dlltest.mak". !MESSAGE !MESSAGE NMAKE ?????s?????\?????w?????????? !MESSAGE ????? ?????????????????????`???????B??: !MESSAGE !MESSAGE NMAKE /f "dlltest.mak" CFG="dlltest - Win32 Debug" !MESSAGE !MESSAGE ?I?????\??????? ????: !MESSAGE !MESSAGE "dlltest - Win32 Release" ("Win32 (x86) Console Application" ?p) !MESSAGE "dlltest - Win32 Debug" ("Win32 (x86) Console Application" ?p) !MESSAGE # Begin Project # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "dlltest - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x411 /d "NDEBUG" # ADD RSC /l 0x411 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 /out:"minibz2.exe" !ELSEIF "$(CFG)" == "dlltest - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "dlltest_" # PROP BASE Intermediate_Dir "dlltest_" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "dlltest_" # PROP Intermediate_Dir "dlltest_" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c # ADD BASE RSC /l 0x411 /d "_DEBUG" # ADD RSC /l 0x411 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /out:"minibz2.exe" /pdbtype:sept !ENDIF # Begin Target # Name "dlltest - Win32 Release" # Name "dlltest - Win32 Debug" # Begin Source File SOURCE=.\bzlib.h # End Source File # Begin Source File SOURCE=.\dlltest.c # End Source File # End Target # End Project --- NEW FILE: huffman.c --- /*-------------------------------------------------------------*/ /*--- Huffman coding low-level stuff ---*/ /*--- huffman.c ---*/ /*-------------------------------------------------------------*/ /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. jseward at acm.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: Mike Burrows David Wheeler Peter Fenwick Alistair Moffat Radford Neal Ian H. Witten Robert Sedgewick Jon L. Bentley For more information on these sources, see the manual. --*/ #include "bzlib_private.h" /*---------------------------------------------------*/ #define WEIGHTOF(zz0) ((zz0) & 0xffffff00) #define DEPTHOF(zz1) ((zz1) & 0x000000ff) #define MYMAX(zz2,zz3) ((zz2) > (zz3) ? (zz2) : (zz3)) #define ADDWEIGHTS(zw1,zw2) \ (WEIGHTOF(zw1)+WEIGHTOF(zw2)) | \ (1 + MYMAX(DEPTHOF(zw1),DEPTHOF(zw2))) #define UPHEAP(z) \ { \ Int32 zz, tmp; \ zz = z; tmp = heap[zz]; \ while (weight[tmp] < weight[heap[zz >> 1]]) { \ heap[zz] = heap[zz >> 1]; \ zz >>= 1; \ } \ heap[zz] = tmp; \ } #define DOWNHEAP(z) \ { \ Int32 zz, yy, tmp; \ zz = z; tmp = heap[zz]; \ while (True) { \ yy = zz << 1; \ if (yy > nHeap) break; \ if (yy < nHeap && \ weight[heap[yy+1]] < weight[heap[yy]]) \ yy++; \ if (weight[tmp] < weight[heap[yy]]) break; \ heap[zz] = heap[yy]; \ zz = yy; \ } \ heap[zz] = tmp; \ } /*---------------------------------------------------*/ void BZ2_hbMakeCodeLengths ( UChar *len, Int32 *freq, Int32 alphaSize, Int32 maxLen ) { /*-- Nodes and heap entries run from 1. Entry 0 for both the heap and nodes is a sentinel. --*/ Int32 nNodes, nHeap, n1, n2, i, j, k; Bool tooLong; Int32 heap [ BZ_MAX_ALPHA_SIZE + 2 ]; Int32 weight [ BZ_MAX_ALPHA_SIZE * 2 ]; Int32 parent [ BZ_MAX_ALPHA_SIZE * 2 ]; for (i = 0; i < alphaSize; i++) weight[i+1] = (freq[i] == 0 ? 1 : freq[i]) << 8; while (True) { nNodes = alphaSize; nHeap = 0; heap[0] = 0; weight[0] = 0; parent[0] = -2; for (i = 1; i <= alphaSize; i++) { parent[i] = -1; nHeap++; heap[nHeap] = i; UPHEAP(nHeap); } AssertH( nHeap < (BZ_MAX_ALPHA_SIZE+2), 2001 ); while (nHeap > 1) { n1 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); n2 = heap[1]; heap[1] = heap[nHeap]; nHeap--; DOWNHEAP(1); nNodes++; parent[n1] = parent[n2] = nNodes; weight[nNodes] = ADDWEIGHTS(weight[n1], weight[n2]); parent[nNodes] = -1; nHeap++; heap[nHeap] = nNodes; UPHEAP(nHeap); } AssertH( nNodes < (BZ_MAX_ALPHA_SIZE * 2), 2002 ); tooLong = False; for (i = 1; i <= alphaSize; i++) { j = 0; k = i; while (parent[k] >= 0) { k = parent[k]; j++; } len[i-1] = j; if (j > maxLen) tooLong = True; } if (! tooLong) break; for (i = 1; i < alphaSize; i++) { j = weight[i] >> 8; j = 1 + (j / 2); weight[i] = j << 8; } } } /*---------------------------------------------------*/ void BZ2_hbAssignCodes ( Int32 *code, UChar *length, Int32 minLen, Int32 maxLen, Int32 alphaSize ) { Int32 n, vec, i; vec = 0; for (n = minLen; n <= maxLen; n++) { for (i = 0; i < alphaSize; i++) if (length[i] == n) { code[i] = vec; vec++; }; vec <<= 1; } } /*---------------------------------------------------*/ void BZ2_hbCreateDecodeTables ( Int32 *limit, Int32 *base, Int32 *perm, UChar *length, Int32 minLen, Int32 maxLen, Int32 alphaSize ) { Int32 pp, i, j, vec; pp = 0; for (i = minLen; i <= maxLen; i++) for (j = 0; j < alphaSize; j++) if (length[j] == i) { perm[pp] = j; pp++; }; for (i = 0; i < BZ_MAX_CODE_LEN; i++) base[i] = 0; for (i = 0; i < alphaSize; i++) base[length[i]+1]++; for (i = 1; i < BZ_MAX_CODE_LEN; i++) base[i] += base[i-1]; for (i = 0; i < BZ_MAX_CODE_LEN; i++) limit[i] = 0; vec = 0; for (i = minLen; i <= maxLen; i++) { vec += (base[i+1] - base[i]); limit[i] = vec-1; vec <<= 1; } for (i = minLen + 1; i <= maxLen; i++) base[i] = ((limit[i-1] + 1) << 1) - base[i]; } /*-------------------------------------------------------------*/ /*--- end huffman.c ---*/ /*-------------------------------------------------------------*/ --- NEW FILE: libbz2.001 --- # Microsoft Developer Studio Project File - Name="libbz2" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 5.00 # ** ???W???????????????? ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=libbz2 - Win32 Debug !MESSAGE ???????L??????????????????????????B ??????????????????????????????? NMAKE ???g?p?????????????B !MESSAGE [????????????????] ????????g?p???????s???????????? !MESSAGE !MESSAGE NMAKE /f "libbz2.mak". !MESSAGE !MESSAGE NMAKE ?????s?????\?????w?????????? !MESSAGE ????? ?????????????????????`???????B??: !MESSAGE !MESSAGE NMAKE /f "libbz2.mak" CFG="libbz2 - Win32 Debug" !MESSAGE !MESSAGE ?I?????\??????? ????: !MESSAGE !MESSAGE "libbz2 - Win32 Release" ("Win32 (x86) Dynamic-Link Library" ?p) !MESSAGE "libbz2 - Win32 Debug" ("Win32 (x86) Dynamic-Link Library" ?p) !MESSAGE # Begin Project # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "libbz2 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o NUL /win32 # ADD BASE RSC /l 0x411 /d "NDEBUG" # ADD RSC /l 0x411 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"libbz2.dll" !ELSEIF "$(CFG)" == "libbz2 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c # ADD CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o NUL /win32 # ADD BASE RSC /l 0x411 /d "_DEBUG" # ADD RSC /l 0x411 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"libbz2.dll" /pdbtype:sept !ENDIF # Begin Target # Name "libbz2 - Win32 Release" # Name "libbz2 - Win32 Debug" # Begin Source File SOURCE=.\blocksort.c # End Source File # Begin Source File SOURCE=.\bzlib.c # End Source File # Begin Source File SOURCE=.\bzlib.h # End Source File # Begin Source File SOURCE=.\bzlib_private.h # End Source File # Begin Source File SOURCE=.\compress.c # End Source File # Begin Source File SOURCE=.\crctable.c # End Source File # Begin Source File SOURCE=.\decompress.c # End Source File # Begin Source File SOURCE=.\huffman.c # End Source File # Begin Source File SOURCE=.\libbz2.def # End Source File # Begin Source File SOURCE=.\randtable.c # End Source File # End Target # End Project --- NEW FILE: libbz2.dsp --- # Microsoft Developer Studio Project File - Name="libbz2" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 CFG=libbz2 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "libbz2.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "libbz2.mak" CFG="libbz2 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "libbz2 - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE "libbz2 - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe MTL=midl.exe RSC=rc.exe !IF "$(CFG)" == "libbz2 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "Release" # PROP BASE Intermediate_Dir "Release" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "Release" # PROP Intermediate_Dir "Release" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x411 /d "NDEBUG" # ADD RSC /l 0x411 /d "NDEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 /out:"libbz2.dll" !ELSEIF "$(CFG)" == "libbz2 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "Debug" # PROP BASE Intermediate_Dir "Debug" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "Debug" # PROP Intermediate_Dir "Debug" # PROP Ignore_Export_Lib 0 # PROP Target_Dir "" # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c # ADD CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD BASE RSC /l 0x411 /d "_DEBUG" # ADD RSC /l 0x411 /d "_DEBUG" BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /pdbtype:sept # ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /debug /machine:I386 /out:"libbz2.dll" /pdbtype:sept !ENDIF # Begin Target # Name "libbz2 - Win32 Release" # Name "libbz2 - Win32 Debug" # Begin Source File SOURCE=.\blocksort.c # End Source File # Begin Source File SOURCE=.\bzlib.c # End Source File # Begin Source File SOURCE=.\bzlib.h # End Source File # Begin Source File SOURCE=.\bzlib_private.h # End Source File # Begin Source File SOURCE=.\compress.c # End Source File # Begin Source File SOURCE=.\crctable.c # End Source File # Begin Source File SOURCE=.\decompress.c # End Source File # Begin Source File SOURCE=.\huffman.c # End Source File # Begin Source File SOURCE=.\libbz2.def # End Source File # Begin Source File SOURCE=.\randtable.c # End Source File # End Target # End Project --- NEW FILE: libbz2.dsw --- Microsoft Developer Studio Workspace File, Format Version 6.00 # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! ############################################################################### Project: "libbz2"=".\libbz2.dsp" - Package Owner=<4> Package=<5> {{{ }}} Package=<4> {{{ }}} ############################################################################### Global: Package=<5> {{{ }}} Package=<3> {{{ }}} ############################################################################### --- NEW FILE: makefile.msc --- # Makefile for Microsoft Visual C++ 6.0 # usage: nmake -f makefile.msc # K.M. Syring (syring at gsf.de) # Fixed up by JRS for bzip2-0.9.5d release. CC=cl CFLAGS= -DWIN32 -MD -Ox -D_FILE_OFFSET_BITS=64 -nologo OBJS= blocksort.obj \ huffman.obj \ crctable.obj \ randtable.obj \ compress.obj \ decompress.obj \ bzlib.obj all: lib bzip2 test bzip2: lib $(CC) $(CFLAGS) -o bzip2 bzip2.c libbz2.lib setargv.obj $(CC) $(CFLAGS) -o bzip2recover bzip2recover.c lib: $(OBJS) lib /out:libbz2.lib $(OBJS) test: bzip2 type words1 .\\bzip2 -1 < sample1.ref > sample1.rb2 .\\bzip2 -2 < sample2.ref > sample2.rb2 .\\bzip2 -3 < sample3.ref > sample3.rb2 .\\bzip2 -d < sample1.bz2 > sample1.tst .\\bzip2 -d < sample2.bz2 > sample2.tst .\\bzip2 -ds < sample3.bz2 > sample3.tst @echo All six of the fc's should find no differences. @echo If fc finds an error on sample3.bz2, this could be @echo because WinZip's 'TAR file smart CR/LF conversion' @echo is too clever for its own good. Disable this option. @echo The correct size for sample3.ref is 120,244. If it @echo is 150,251, WinZip has messed it up. fc sample1.bz2 sample1.rb2 fc sample2.bz2 sample2.rb2 fc sample3.bz2 sample3.rb2 fc sample1.tst sample1.ref fc sample2.tst sample2.ref fc sample3.tst sample3.ref clean: del *.obj del libbz2.lib del bzip2.exe del bzip2recover.exe del sample1.rb2 del sample2.rb2 del sample3.rb2 del sample1.tst del sample2.tst del sample3.tst .c.obj: $(CC) $(CFLAGS) -c $*.c -o $*.obj --- NEW FILE: manual.html --- Untitled Document: Untitled Document
[Top] [Contents] [Index] [ ? ]

Untitled Document

The following text is the License for this software. You should find it identical to that contained in the file LICENSE in the source distribution.

@bf{------------------ START OF THE LICENSE ------------------}

This program, bzip2, and associated library libbzip2, are Copyright (C) 1996-2002 Julian R Seward. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  • The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required.
  • Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software.
  • The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Julian Seward, Cambridge, UK.

jseward at acm.org

bzip2/libbzip2 version 1.0.2 of 30 December 2001.

@bf{------------------ END OF THE LICENSE ------------------}

Web sites:

http://sources.redhat.com/bzip2

http://www.cacheprof.org

PATENTS: To the best of my knowledge, bzip2 does not use any patented algorithms. However, I do not have the resources available to carry out a full patent search. Therefore I cannot give any guarantee of the above statement.



This document was generated by Julian Seward on January, 5 2002 using texi2html --- NEW FILE: manual.pdf --- %PDF-1.2 %???? 6 0 obj <> stream x??Q?S?@-?EOG???p?l????.wI/J?h?m1??????P??R?O??s3???v??7K ??u??%????@????Q???"o?gh4??$?? ??4?F????x???????,Rm? j???}???jP??w?XxP?{?g"N????????D??""%??KB??i;A^???~?"??????vTH????$g?g?q@???Q??1m ?b?6py??s3?T?-(?p??b??5?-l>? g?n??hY???m?^?YtN???zVMxZ,?]???P????h??Z???u?????81?i??3?]?O?????????S?v%'?B???????l?I?j9?^??}?)Y8k?NL?2?z????[?????ki?o?x$?D???C??}d?~??Y?OO????_|???|J?hK,??m??~m?}endstream endobj 7 0 obj 437 endobj 117 0 obj <> endobj 118 0 obj <> endobj 120 0 obj [...12830 lines suppressed...] 0000262460 00000 n 0000262737 00000 n 0000263105 00000 n 0000263337 00000 n 0000263536 00000 n 0000263828 00000 n 0000264107 00000 n 0000264296 00000 n 0000131795 00000 n 0000139083 00000 n 0000131977 00000 n 0000132916 00000 n 0000264588 00000 n 0000132937 00000 n trailer << /Size 763 /Root 1 0 R /Info 2 0 R >> startxref 282925 %%EOF --- NEW FILE: manual.ps --- %!PS-Adobe-2.0 %%Creator: dvips(k) 5.86 Copyright 1999 Radical Eye Software %%Title: manual.dvi %%Pages: 40 %%PageOrder: Ascend %%BoundingBox: 0 0 596 842 %%EndComments %DVIPSWebPage: (www.radicaleye.com) %DVIPSCommandLine: dvips -o manual.ps manual.dvi %DVIPSParameters: dpi=600, compressed %DVIPSSource: TeX output 2002.01.05:0052 %%BeginProcSet: texc.pro %! /TeXDict 300 dict def TeXDict begin/N{def}def/B{bind def}N/S{exch}N/X{S N}B/A{dup}B/TR{translate}N/isls false N/vsize 11 72 mul N/hsize 8.5 72 mul N/landplus90{false}def/@rigin{isls{[0 landplus90{1 -1}{-1 1}ifelse 0 0 0]concat}if 72 Resolution div 72 VResolution div neg scale isls{ landplus90{VResolution 72 div vsize mul 0 exch}{Resolution -72 div hsize mul 0}ifelse TR}if Resolution VResolution vsize -72 div 1 add mul TR[ [...3952 lines suppressed...] (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.) g(.)g(.)g(.)g(.)41 b Fl(33)449 901 y Fj(4.3)92 b(Rep)s(orting)31 b(bugs)24 b Fb(.)15 b(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)54 b Fl(33)449 1010 y Fj(4.4)92 b(Did)30 b(y)m(ou)g(get)i(the)f(righ)m(t)g(pac)m(k)-5 b(age?)18 b Fb(.)f(.)e(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)47 b Fl(35)449 1120 y Fj(4.5)92 b(T)-8 b(esting)16 b Fb(.)h(.)e(.)g(.)g(.)g(.)g(.)g(.) g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)h(.)f(.)g(.)g(.)g(.)g (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) g(.)g(.)g(.)g(.)g(.)46 b Fl(35)449 1230 y Fj(4.6)92 b(F)-8 b(urther)30 b(reading)17 b Fb(.)f(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g (.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.) g(.)g(.)h(.)f(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)g(.)46 b Fl(36)p eop %%Trailer end userdict /end-hook known{end-hook}if %%EOF --- NEW FILE: manual.texi --- \input texinfo @c -*- Texinfo -*- @setfilename bzip2.info @ignore This file documents bzip2 version 1.0.2, and associated library libbzip2, written by Julian Seward (jseward at acm.org). Copyright (C) 1996-2002 Julian R Seward Permission is granted to make and distribute verbatim copies of this manual provided the copyright notice and this permission notice are preserved on all copies. Permission is granted to copy and distribute translations of this manual into another language, under the above conditions for verbatim copies. @end ignore @ifinfo @format [...2204 lines suppressed...] The Manber-Myers suffix array construction algorithm is described in a paper available from: @example http://www.cs.arizona.edu/people/gene/PAPERS/suffix.ps @end example Finally, the following paper documents some recent investigations I made into the performance of sorting algorithms: @example Julian Seward: On the Performance of BWT Sorting Algorithms Proceedings of the IEEE Data Compression Conference 2000 Snowbird, Utah. 28-30 March 2000. @end example @contents @bye --- NEW FILE: manual_1.html --- Untitled Document: 1. Introduction
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

1. Introduction

bzip2 compresses files using the Burrows-Wheeler block-sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than that achieved by more conventional LZ77/LZ78-based compressors, and approaches the performance of the PPM family of statistical compressors.

bzip2 is built on top of libbzip2, a flexible library for handling compressed data in the bzip2 format. This manual describes both how to use the program and how to work with the library interface. Most of the manual is devoted to this library, not the program, which is good news if your interest is only in the program.

Chapter 2 describes how to use bzip2; this is the only part you need to read if you just want to know how to operate the program. Chapter 3 describes the programming interfaces in detail, and Chapter 4 records some miscellaneous notes which I thought ought to be recorded somewhere.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Julian Seward on January, 5 2002 using texi2html --- NEW FILE: manual_2.html --- Untitled Document: 2. How to use <CODE>bzip2</CODE>
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

2. How to use bzip2

This chapter contains a copy of the bzip2 man page, and nothing else.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

NAME

  • bzip2, bunzip2 - a block-sorting file compressor, v1.0.2
  • bzcat - decompresses files to stdout
  • bzip2recover - recovers data from damaged bzip2 files


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

SYNOPSIS

  • bzip2 [ -cdfkqstvzVL123456789 ] [ filenames ... ]
  • bunzip2 [ -fkvsVL ] [ filenames ... ]
  • bzcat [ -s ] [ filenames ... ]
  • bzip2recover filename


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

DESCRIPTION

bzip2 compresses files using the Burrows-Wheeler block sorting text compression algorithm, and Huffman coding. Compression is generally considerably better than that achieved by more conventional LZ77/LZ78-based compressors, and approaches the performance of the PPM family of statistical compressors.

The command-line options are deliberately very similar to those of GNU gzip, but they are not identical.

bzip2 expects a list of file names to accompany the command-line flags. Each file is replaced by a compressed version of itself, with the name original_name.bz2. Each compressed file has the same modification date, permissions, and, when possible, ownership as the corresponding original, so that these properties can be correctly restored at decompression time. File name handling is naive in the sense that there is no mechanism for preserving original file names, permissions, ownerships or dates in filesystems which lack these concepts, or have serious file name length restrictions, such as MS-DOS.

bzip2 and bunzip2 will by default not overwrite existing files. If you want this to happen, specify the -f flag.

If no file names are specified, bzip2 compresses from standard input to standard output. In this case, bzip2 will decline to write compressed output to a terminal, as this would be entirely incomprehensible and therefore pointless.

bunzip2 (or bzip2 -d) decompresses all specified files. Files which were not created by bzip2 will be detected and ignored, and a warning issued. bzip2 attempts to guess the filename for the decompressed file from that of the compressed file as follows:

  • filename.bz2 becomes filename
  • filename.bz becomes filename
  • filename.tbz2 becomes filename.tar
  • filename.tbz becomes filename.tar
  • anyothername becomes anyothername.out
If the file does not end in one of the recognised endings, .bz2, .bz, .tbz2 or .tbz, bzip2 complains that it cannot guess the name of the original file, and uses the original name with .out appended.

As with compression, supplying no filenames causes decompression from standard input to standard output.

bunzip2 will correctly decompress a file which is the concatenation of two or more compressed files. The result is the concatenation of the corresponding uncompressed files. Integrity testing (-t) of concatenated compressed files is also supported.

You can also compress or decompress files to the standard output by giving the -c flag. Multiple files may be compressed and decompressed like this. The resulting outputs are fed sequentially to stdout. Compression of multiple files in this manner generates a stream containing multiple compressed file representations. Such a stream can be decompressed correctly only by bzip2 version 0.9.0 or later. Earlier versions of bzip2 will stop after decompressing the first file in the stream.

bzcat (or bzip2 -dc) decompresses all specified files to the standard output.

bzip2 will read arguments from the environment variables BZIP2 and BZIP, in that order, and will process them before any arguments read from the command line. This gives a convenient way to supply default arguments.

Compression is always performed, even if the compressed file is slightly larger than the original. Files of less than about one hundred bytes tend to get larger, since the compression mechanism has a constant overhead in the region of 50 bytes. Random data (including the output of most file compressors) is coded at about 8.05 bits per byte, giving an expansion of around 0.5%.

As a self-check for your protection, bzip2 uses 32-bit CRCs to make sure that the decompressed version of a file is identical to the original. This guards against corruption of the compressed data, and against undetected bugs in bzip2 (hopefully very unlikely). The chances of data corruption going undetected is microscopic, about one chance in four billion for each file processed. Be aware, though, that the check occurs upon decompression, so it can only tell you that something is wrong. It can't help you recover the original uncompressed data. You can use bzip2recover to try to recover data from damaged files.

Return values: 0 for a normal exit, 1 for environmental problems (file not found, invalid flags, I/O errors, &c), 2 to indicate a corrupt compressed file, 3 for an internal consistency error (eg, bug) which caused bzip2 to panic.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

OPTIONS

-c --stdout
Compress or decompress to standard output.
-d --decompress
Force decompression. bzip2, bunzip2 and bzcat are really the same program, and the decision about what actions to take is done on the basis of which name is used. This flag overrides that mechanism, and forces bzip2 to decompress.
-z --compress
The complement to -d: forces compression, regardless of the invokation name.
-t --test
Check integrity of the specified file(s), but don't decompress them. This really performs a trial decompression and throws away the result.
-f --force
Force overwrite of output files. Normally, bzip2 will not overwrite existing output files. Also forces bzip2 to break hard links to files, which it otherwise wouldn't do.

bzip2 normally declines to decompress files which don't have the correct magic header bytes. If forced (-f), however, it will pass such files through unmodified. This is how GNU gzip behaves.

-k --keep
Keep (don't delete) input files during compression or decompression.
-s --small
Reduce memory usage, for compression, decompression and testing. Files are decompressed and tested using a modified algorithm which only requires 2.5 bytes per block byte. This means any file can be decompressed in 2300k of memory, albeit at about half the normal speed.

During compression, -s selects a block size of 200k, which limits memory use to around the same figure, at the expense of your compression ratio. In short, if your machine is low on memory (8 megabytes or less), use -s for everything. See MEMORY MANAGEMENT below.

-q --quiet
Suppress non-essential warning messages. Messages pertaining to I/O errors and other critical events will not be suppressed.
-v --verbose
Verbose mode -- show the compression ratio for each file processed. Further -v's increase the verbosity level, spewing out lots of information which is primarily of interest for diagnostic purposes.
-L --license -V --version
Display the software version, license terms and conditions.
-1 (or --fast) to -9 (or --best)
Set the block size to 100 k, 200 k .. 900 k when compressing. Has no effect when decompressing. See MEMORY MANAGEMENT below. The --fast and --best aliases are primarily for GNU gzip compatibility. In particular, --fast doesn't make things significantly faster. And --best merely selects the default behaviour.
--
Treats all subsequent arguments as file names, even if they start with a dash. This is so you can handle files with names beginning with a dash, for example: bzip2 -- -myfilename.
--repetitive-fast
--repetitive-best
These flags are redundant in versions 0.9.5 and above. They provided some coarse control over the behaviour of the sorting algorithm in earlier versions, which was sometimes useful. 0.9.5 and above have an improved algorithm which renders these flags irrelevant.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

MEMORY MANAGEMENT

bzip2 compresses large files in blocks. The block size affects both the compression ratio achieved, and the amount of memory needed for compression and decompression. The flags -1 through -9 specify the block size to be 100,000 bytes through 900,000 bytes (the default) respectively. At decompression time, the block size used for compression is read from the header of the compressed file, and bunzip2 then allocates itself just enough memory to decompress the file. Since block sizes are stored in compressed files, it follows that the flags -1 to -9 are irrelevant to and so ignored during decompression.

Compression and decompression requirements, in bytes, can be estimated as:
 
     Compression:   400k + ( 8 x block size )

     Decompression: 100k + ( 4 x block size ), or
                    100k + ( 2.5 x block size )
Larger block sizes give rapidly diminishing marginal returns. Most of the compression comes from the first two or three hundred k of block size, a fact worth bearing in mind when using bzip2 on small machines. It is also important to appreciate that the decompression memory requirement is set at compression time by the choice of block size.

For files compressed with the default 900k block size, bunzip2 will require about 3700 kbytes to decompress. To support decompression of any file on a 4 megabyte machine, bunzip2 has an option to decompress using approximately half this amount of memory, about 2300 kbytes. Decompression speed is also halved, so you should use this option only where necessary. The relevant flag is -s.

In general, try and use the largest block size memory constraints allow, since that maximises the compression achieved. Compression and decompression speed are virtually unaffected by block size.

Another significant point applies to files which fit in a single block -- that means most files you'd encounter using a large block size. The amount of real memory touched is proportional to the size of the file, since the file is smaller than a block. For example, compressing a file 20,000 bytes long with the flag -9 will cause the compressor to allocate around 7600k of memory, but only touch 400k + 20000 * 8 = 560 kbytes of it. Similarly, the decompressor will allocate 3700k but only touch 100k + 20000 * 4 = 180 kbytes.

Here is a table which summarises the maximum memory usage for different block sizes. Also recorded is the total compressed size for 14 files of the Calgary Text Compression Corpus totalling 3,141,622 bytes. This column gives some feel for how compression varies with block size. These figures tend to understate the advantage of larger block sizes for larger files, since the Corpus is dominated by smaller files.
 
          Compress   Decompress   Decompress   Corpus
   Flag     usage      usage       -s usage     Size

    -1      1200k       500k         350k      914704
    -2      2000k       900k         600k      877703
    -3      2800k      1300k         850k      860338
    -4      3600k      1700k        1100k      846899
    -5      4400k      2100k        1350k      845160
    -6      5200k      2500k        1600k      838626
    -7      6100k      2900k        1850k      834096
    -8      6800k      3300k        2100k      828642
    -9      7600k      3700k        2350k      828642


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

RECOVERING DATA FROM DAMAGED FILES

bzip2 compresses files in blocks, usually 900kbytes long. Each block is handled independently. If a media or transmission error causes a multi-block .bz2 file to become damaged, it may be possible to recover data from the undamaged blocks in the file.

The compressed representation of each block is delimited by a 48-bit pattern, which makes it possible to find the block boundaries with reasonable certainty. Each block also carries its own 32-bit CRC, so damaged blocks can be distinguished from undamaged ones.

bzip2recover is a simple program whose purpose is to search for blocks in .bz2 files, and write each block out into its own .bz2 file. You can then use bzip2 -t to test the integrity of the resulting files, and decompress those which are undamaged.

bzip2recover takes a single argument, the name of the damaged file, and writes a number of files rec00001file.bz2, rec00002file.bz2, etc, containing the extracted blocks. The output filenames are designed so that the use of wildcards in subsequent processing -- for example, bzip2 -dc rec*file.bz2 > recovered_data -- processes the files in the correct order.

bzip2recover should be of most use dealing with large .bz2 files, as these will contain many blocks. It is clearly futile to use it on damaged single-block files, since a damaged block cannot be recovered. If you wish to minimise any potential data loss through media or transmission errors, you might consider compressing with a smaller block size.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

PERFORMANCE NOTES

The sorting phase of compression gathers together similar strings in the file. Because of this, files containing very long runs of repeated symbols, like "aabaabaabaab ..." (repeated several hundred times) may compress more slowly than normal. Versions 0.9.5 and above fare much better than previous versions in this respect. The ratio between worst-case and average-case compression time is in the region of 10:1. For previous versions, this figure was more like 100:1. You can use the -vvvv option to monitor progress in great detail, if you want.

Decompression speed is unaffected by these phenomena.

bzip2 usually allocates several megabytes of memory to operate in, and then charges all over it in a fairly random fashion. This means that performance, both for compressing and decompressing, is largely determined by the speed at which your machine can service cache misses. Because of this, small changes to the code to reduce the miss rate have been observed to give disproportionately large performance improvements. I imagine bzip2 will perform best on machines with very large caches.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

CAVEATS

I/O error messages are not as helpful as they could be. bzip2 tries hard to detect I/O errors and exit cleanly, but the details of what the problem is sometimes seem rather misleading.

This manual page pertains to version 1.0.2 of bzip2. Compressed data created by this version is entirely forwards and backwards compatible with the previous public releases, versions 0.1pl2, 0.9.0, 0.9.5, 1.0.0 and 1.0.1, but with the following exception: 0.9.0 and above can correctly decompress multiple concatenated compressed files. 0.1pl2 cannot do this; it will stop after decompressing just the first file in the stream.

bzip2recover versions prior to this one, 1.0.2, used 32-bit integers to represent bit positions in compressed files, so it could not handle compressed files more than 512 megabytes long. Version 1.0.2 and above uses 64-bit ints on some platforms which support them (GNU supported targets, and Windows). To establish whether or not bzip2recover was built with such a limitation, run it without arguments. In any event you can build yourself an unlimited version if you can recompile it with MaybeUInt64 set to be an unsigned 64-bit integer.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

AUTHOR

Julian Seward, jseward at acm.org.

http://sources.redhat.com/bzip2

The ideas embodied in bzip2 are due to (at least) the following people: Michael Burrows and David Wheeler (for the block sorting transformation), David Wheeler (again, for the Huffman coder), Peter Fenwick (for the structured coding model in the original bzip, and many refinements), and Alistair Moffat, Radford Neal and Ian Witten (for the arithmetic coder in the original bzip). I am much indebted for their help, support and advice. See the manual in the source distribution for pointers to sources of documentation. Christian von Roques encouraged me to look for faster sorting algorithms, so as to speed up compression. Bela Lubkin encouraged me to improve the worst-case compression performance. The bz* scripts are derived from those of GNU gzip. Many people sent patches, helped with portability problems, lent machines, gave advice and were generally helpful.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Julian Seward on January, 5 2002 using texi2html --- NEW FILE: manual_3.html --- Untitled Document: 3. Programming with <CODE>libbzip2</CODE> [...1816 lines suppressed...]


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Julian Seward on January, 5 2002 using texi2html --- NEW FILE: manual_4.html --- Untitled Document: 4. Miscellanea
[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4. Miscellanea

These are just some random thoughts of mine. Your mileage may vary.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.1 Limitations of the compressed file format

bzip2-1.0, 0.9.5 and 0.9.0 use exactly the same file format as the previous version, bzip2-0.1. This decision was made in the interests of stability. Creating yet another incompatible compressed file format would create further confusion and disruption for users.

Nevertheless, this is not a painless decision. Development work since the release of bzip2-0.1 in August 1997 has shown complexities in the file format which slow down decompression and, in retrospect, are unnecessary. These are:

  • The run-length encoder, which is the first of the compression transformations, is entirely irrelevant. The original purpose was to protect the sorting algorithm from the very worst case input: a string of repeated symbols. But algorithm steps Q6a and Q6b in the original Burrows-Wheeler technical report (SRC-124) show how repeats can be handled without difficulty in block sorting.
  • The randomisation mechanism doesn't really need to be there. Udi Manber and Gene Myers published a suffix array construction algorithm a few years back, which can be employed to sort any block, no matter how repetitive, in O(N log N) time. Subsequent work by Kunihiko Sadakane has produced a derivative O(N (log N)^2) algorithm which usually outperforms the Manber-Myers algorithm.

    I could have changed to Sadakane's algorithm, but I find it to be slower than bzip2's existing algorithm for most inputs, and the randomisation mechanism protects adequately against bad cases. I didn't think it was a good tradeoff to make. Partly this is due to the fact that I was not flooded with email complaints about bzip2-0.1's performance on repetitive data, so perhaps it isn't a problem for real inputs.

    Probably the best long-term solution, and the one I have incorporated into 0.9.5 and above, is to use the existing sorting algorithm initially, and fall back to a O(N (log N)^2) algorithm if the standard algorithm gets into difficulties.

  • The compressed file format was never designed to be handled by a library, and I have had to jump though some hoops to produce an efficient implementation of decompression. It's a bit hairy. Try passing decompress.c through the C preprocessor and you'll see what I mean. Much of this complexity could have been avoided if the compressed size of each block of data was recorded in the data stream.
  • An Adler-32 checksum, rather than a CRC32 checksum, would be faster to compute.
It would be fair to say that the bzip2 format was frozen before I properly and fully understood the performance consequences of doing so.

Improvements which I was able to incorporate into 0.9.0, despite using the same file format, are:

  • Single array implementation of the inverse BWT. This significantly speeds up decompression, presumably because it reduces the number of cache misses.
  • Faster inverse MTF transform for large MTF values. The new implementation is based on the notion of sliding blocks of values.
  • bzip2-0.9.0 now reads and writes files with fread and fwrite; version 0.1 used putc and getc. Duh! Well, you live and learn.

Further ahead, it would be nice to be able to do random access into files. This will require some careful design of compressed file formats.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.2 Portability issues

After some consideration, I have decided not to use GNU autoconf to configure 0.9.5 or 1.0.

autoconf, admirable and wonderful though it is, mainly assists with portability problems between Unix-like platforms. But bzip2 doesn't have much in the way of portability problems on Unix; most of the difficulties appear when porting to the Mac, or to Microsoft's operating systems. autoconf doesn't help in those cases, and brings in a whole load of new complexity.

Most people should be able to compile the library and program under Unix straight out-of-the-box, so to speak, especially if you have a version of GNU C available.

There are a couple of __inline__ directives in the code. GNU C (gcc) should be able to handle them. If you're not using GNU C, your C compiler shouldn't see them at all. If your compiler does, for some reason, see them and doesn't like them, just #define __inline__ to be /* */. One easy way to do this is to compile with the flag -D__inline__=, which should be understood by most Unix compilers.

If you still have difficulties, try compiling with the macro BZ_STRICT_ANSI defined. This should enable you to build the library in a strictly ANSI compliant environment. Building the program itself like this is dangerous and not supported, since you remove bzip2's checks against compressing directories, symbolic links, devices, and other not-really-a-file entities. This could cause filesystem corruption!

One other thing: if you create a bzip2 binary for public distribution, please try and link it statically (gcc -s). This avoids all sorts of library-version issues that others may encounter later on.

If you build bzip2 on Win32, you must set BZ_UNIX to 0 and BZ_LCCWIN32 to 1, in the file bzip2.c, before compiling. Otherwise the resulting binary won't work correctly.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.3 Reporting bugs

I tried pretty hard to make sure bzip2 is bug free, both by design and by testing. Hopefully you'll never need to read this section for real.

Nevertheless, if bzip2 dies with a segmentation fault, a bus error or an internal assertion failure, it will ask you to email me a bug report. Experience with version 0.1 shows that almost all these problems can be traced to either compiler bugs or hardware problems.

  • Recompile the program with no optimisation, and see if it works. And/or try a different compiler. I heard all sorts of stories about various flavours of GNU C (and other compilers) generating bad code for bzip2, and I've run across two such examples myself.

    2.7.X versions of GNU C are known to generate bad code from time to time, at high optimisation levels. If you get problems, try using the flags -O2 -fomit-frame-pointer -fno-strength-reduce. You should specifically not use -funroll-loops.

    You may notice that the Makefile runs six tests as part of the build process. If the program passes all of these, it's a pretty good (but not 100%) indication that the compiler has done its job correctly.

  • If bzip2 crashes randomly, and the crashes are not repeatable, you may have a flaky memory subsystem. bzip2 really hammers your memory hierarchy, and if it's a bit marginal, you may get these problems. Ditto if your disk or I/O subsystem is slowly failing. Yup, this really does happen.

    Try using a different machine of the same type, and see if you can repeat the problem.

  • This isn't really a bug, but ... If bzip2 tells you your file is corrupted on decompression, and you obtained the file via FTP, there is a possibility that you forgot to tell FTP to do a binary mode transfer. That absolutely will cause the file to be non-decompressible. You'll have to transfer it again.

If you've incorporated libbzip2 into your own program and are getting problems, please, please, please, check that the parameters you are passing in calls to the library, are correct, and in accordance with what the documentation says is allowable. I have tried to make the library robust against such problems, but I'm sure I haven't succeeded.

Finally, if the above comments don't help, you'll have to send me a bug report. Now, it's just amazing how many people will send me a bug report saying something like
 
   bzip2 crashed with segmentation fault on my machine
and absolutely nothing else. Needless to say, a such a report is totally, utterly, completely and comprehensively 100% useless; a waste of your time, my time, and net bandwidth. With no details at all, there's no way I can possibly begin to figure out what the problem is.

The rules of the game are: facts, facts, facts. Don't omit them because "oh, they won't be relevant". At the bare minimum:
 
   Machine type.  Operating system version.  
   Exact version of bzip2 (do bzip2 -V).  
   Exact version of the compiler used.  
   Flags passed to the compiler.
However, the most important single thing that will help me is the file that you were trying to compress or decompress at the time the problem happened. Without that, my ability to do anything more than speculate about the cause, is limited.

Please remember that I connect to the Internet with a modem, so you should contact me before mailing me huge files.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.4 Did you get the right package?

bzip2 is a resource hog. It soaks up large amounts of CPU cycles and memory. Also, it gives very large latencies. In the worst case, you can feed many megabytes of uncompressed data into the library before getting any compressed output, so this probably rules out applications requiring interactive behaviour.

These aren't faults of my implementation, I hope, but more an intrinsic property of the Burrows-Wheeler transform (unfortunately). Maybe this isn't what you want.

If you want a compressor and/or library which is faster, uses less memory but gets pretty good compression, and has minimal latency, consider Jean-loup Gailly's and Mark Adler's work, zlib-1.1.3 and gzip-1.2.4. Look for them at

http://www.zlib.org and http://www.gzip.org respectively.

For something faster and lighter still, you might try Markus F X J Oberhumer's LZO real-time compression/decompression library, at
http://wildsau.idv.uni-linz.ac.at/mfx/lzo.html.

If you want to use the bzip2 algorithms to compress small blocks of data, 64k bytes or smaller, for example on an on-the-fly disk compressor, you'd be well advised not to use this library. Instead, I've made a special library tuned for that kind of use. It's part of e2compr-0.40, an on-the-fly disk compressor for the Linux ext2 filesystem. Look at http://www.netspace.net.au/~reiter/e2compr.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.5 Testing

A record of the tests I've done.

First, some data sets:

  • B: a directory containing 6001 files, one for every length in the range 0 to 6000 bytes. The files contain random lowercase letters. 18.7 megabytes.
  • H: my home directory tree. Documents, source code, mail files, compressed data. H contains B, and also a directory of files designed as boundary cases for the sorting; mostly very repetitive, nasty files. 565 megabytes.
  • A: directory tree holding various applications built from source: egcs, gcc-2.8.1, KDE, GTK, Octave, etc. 2200 megabytes.
The tests conducted are as follows. Each test means compressing (a copy of) each file in the data set, decompressing it and comparing it against the original.

First, a bunch of tests with block sizes and internal buffer sizes set very small, to detect any problems with the blocking and buffering mechanisms. This required modifying the source code so as to try to break it.

  1. Data set H, with buffer size of 1 byte, and block size of 23 bytes.
  2. Data set B, buffer sizes 1 byte, block size 1 byte.
  3. As (2) but small-mode decompression.
  4. As (2) with block size 2 bytes.
  5. As (2) with block size 3 bytes.
  6. As (2) with block size 4 bytes.
  7. As (2) with block size 5 bytes.
  8. As (2) with block size 6 bytes and small-mode decompression.
  9. H with buffer size of 1 byte, but normal block size (up to 900000 bytes).
Then some tests with unmodified source code.
  1. H, all settings normal.
  2. As (1), with small-mode decompress.
  3. H, compress with flag -1.
  4. H, compress with flag -s, decompress with flag -s.
  5. Forwards compatibility: H, bzip2-0.1pl2 compressing, bzip2-0.9.5 decompressing, all settings normal.
  6. Backwards compatibility: H, bzip2-0.9.5 compressing, bzip2-0.1pl2 decompressing, all settings normal.
  7. Bigger tests: A, all settings normal.
  8. As (7), using the fallback (Sadakane-like) sorting algorithm.
  9. As (8), compress with flag -1, decompress with flag -s.
  10. H, using the fallback sorting algorithm.
  11. Forwards compatibility: A, bzip2-0.1pl2 compressing, bzip2-0.9.5 decompressing, all settings normal.
  12. Backwards compatibility: A, bzip2-0.9.5 compressing, bzip2-0.1pl2 decompressing, all settings normal.
  13. Misc test: about 400 megabytes of .tar files with bzip2 compiled with Checker (a memory access error detector, like Purify).
  14. Misc tests to make sure it builds and runs ok on non-Linux/x86 platforms.
These tests were conducted on a 225 MHz IDT WinChip machine, running Linux 2.0.36. They represent nearly a week of continuous computation. All tests completed successfully.


[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

4.6 Further reading

bzip2 is not research work, in the sense that it doesn't present any new ideas. Rather, it's an engineering exercise based on existing ideas.

Four documents describe essentially all the ideas behind bzip2:
 
Michael Burrows and D. J. Wheeler:
  "A block-sorting lossless data compression algorithm"
   10th May 1994. 
   Digital SRC Research Report 124.
   ftp://ftp.digital.com/pub/DEC/SRC/research-reports/SRC-124.ps.gz
   If you have trouble finding it, try searching at the
   New Zealand Digital Library, http://www.nzdl.org.

Daniel S. Hirschberg and Debra A. LeLewer
  "Efficient Decoding of Prefix Codes"
   Communications of the ACM, April 1990, Vol 33, Number 4.
   You might be able to get an electronic copy of this
      from the ACM Digital Library.

David J. Wheeler
   Program bred3.c and accompanying document bred3.ps.
   This contains the idea behind the multi-table Huffman
   coding scheme.
   ftp://ftp.cl.cam.ac.uk/users/djw3/

Jon L. Bentley and Robert Sedgewick
  "Fast Algorithms for Sorting and Searching Strings"
   Available from Sedgewick's web page,
   www.cs.princeton.edu/~rs
The following paper gives valuable additional insights into the algorithm, but is not immediately the basis of any code used in bzip2.
 
Peter Fenwick:
   Block Sorting Text Compression
   Proceedings of the 19th Australasian Computer Science Conference,
     Melbourne, Australia.  Jan 31 - Feb 2, 1996.
   ftp://ftp.cs.auckland.ac.nz/pub/peter-f/ACSC96paper.ps
Kunihiko Sadakane's sorting algorithm, mentioned above, is available from:
 
http://naomi.is.s.u-tokyo.ac.jp/~sada/papers/Sada98b.ps.gz
The Manber-Myers suffix array construction algorithm is described in a paper available from:
 
http://www.cs.arizona.edu/people/gene/PAPERS/suffix.ps
Finally, the following paper documents some recent investigations I made into the performance of sorting algorithms:
 
Julian Seward:
   On the Performance of BWT Sorting Algorithms
   Proceedings of the IEEE Data Compression Conference 2000
     Snowbird, Utah.  28-30 March 2000.


[ << ] [ >> ]           [Top] [Contents] [Index] [ ? ]

This document was generated by Julian Seward on January, 5 2002 using texi2html --- NEW FILE: manual_abt.html --- Untitled Document: About this document
[Top] [Contents] [Index] [ ? ]

About this document

This document was generated by Julian Seward on January, 5 2002 using texi2html

The buttons in the navigation panels have the following meaning:

Button Name Go to From 1.2.3 go to
[ < ] Back previous section in reading order 1.2.2
[ > ] Forward next section in reading order 1.2.4
[ << ] FastBack previous or up-and-previous section 1.1
[ Up ] Up up section 1.2
[ >> ] FastForward next or up-and-next section 1.3
[Top] Top cover (top) of document  
[Contents] Contents table of contents  
[Index] Index concept index  
[ ? ] About this page  

where the Example assumes that the current position is at Subsubsection One-Two-Three of a document of the following structure:
  • 1. Section One
    • 1.1 Subsection One-One
      • ...
    • 1.2 Subsection One-Two
      • 1.2.1 Subsubsection One-Two-One
      • 1.2.2 Subsubsection One-Two-Two
      • 1.2.3 Subsubsection One-Two-Three     <== Current Position
      • 1.2.4 Subsubsection One-Two-Four
    • 1.3 Subsection One-Three
      • ...
    • 1.4 Subsection One-Four


This document was generated by Julian Seward on January, 5 2002 using texi2html --- NEW FILE: manual_ovr.html --- Untitled Document: Short Table of Contents
[Top] [Contents] [Index] [ ? ]

Short Table of Contents

1. Introduction
2. How to use bzip2
3. Programming with libbzip2
4. Miscellanea


This document was generated by Julian Seward on January, 5 2002 using texi2html --- NEW FILE: manual_toc.html --- Untitled Document: Table of Contents
[Top] [Contents] [Index] [ ? ]

Table of Contents



This document was generated by Julian Seward on January, 5 2002 using texi2html --- NEW FILE: mk251.c --- /* Spew out a long sequence of the byte 251. When fed to bzip2 versions 1.0.0 or 1.0.1, causes it to die with internal error 1007 in blocksort.c. This assertion misses an extremely rare case, which is fixed in this version (1.0.2) and above. */ #include int main () { int i; for (i = 0; i < 48500000 ; i++) putchar(251); return 0; } --- NEW FILE: randtable.c --- /*-------------------------------------------------------------*/ /*--- Table for randomising repetitive blocks ---*/ /*--- randtable.c ---*/ /*-------------------------------------------------------------*/ /*-- This file is a part of bzip2 and/or libbzip2, a program and library for lossless, block-sorting data compression. Copyright (C) 1996-2002 Julian R Seward. All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 3. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 4. The name of the author may not be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Julian Seward, Cambridge, UK. jseward at acm.org bzip2/libbzip2 version 1.0 of 21 March 2000 This program is based on (at least) the work of: Mike Burrows David Wheeler Peter Fenwick Alistair Moffat Radford Neal Ian H. Witten Robert Sedgewick Jon L. Bentley For more information on these sources, see the manual. --*/ #include "bzlib_private.h" /*---------------------------------------------*/ Int32 BZ2_rNums[512] = { 619, 720, 127, 481, 931, 816, 813, 233, 566, 247, 985, 724, 205, 454, 863, 491, 741, 242, 949, 214, 733, 859, 335, 708, 621, 574, 73, 654, 730, 472, 419, 436, 278, 496, 867, 210, 399, 680, 480, 51, 878, 465, 811, 169, 869, 675, 611, 697, 867, 561, 862, 687, 507, 283, 482, 129, 807, 591, 733, 623, 150, 238, 59, 379, 684, 877, 625, 169, 643, 105, 170, 607, 520, 932, 727, 476, 693, 425, 174, 647, 73, 122, 335, 530, 442, 853, 695, 249, 445, 515, 909, 545, 703, 919, 874, 474, 882, 500, 594, 612, 641, 801, 220, 162, 819, 984, 589, 513, 495, 799, 161, 604, 958, 533, 221, 400, 386, 867, 600, 782, 382, 596, 414, 171, 516, 375, 682, 485, 911, 276, 98, 553, 163, 354, 666, 933, 424, 341, 533, 870, 227, 730, 475, 186, 263, 647, 537, 686, 600, 224, 469, 68, 770, 919, 190, 373, 294, 822, 808, 206, 184, 943, 795, 384, 383, 461, 404, 758, 839, 887, 715, 67, 618, 276, 204, 918, 873, 777, 604, 560, 951, 160, 578, 722, 79, 804, 96, 409, 713, 940, 652, 934, 970, 447, 318, 353, 859, 672, 112, 785, 645, 863, 803, 350, 139, 93, 354, 99, 820, 908, 609, 772, 154, 274, 580, 184, 79, 626, 630, 742, 653, 282, 762, 623, 680, 81, 927, 626, 789, 125, 411, 521, 938, 300, 821, 78, 343, 175, 128, 250, 170, 774, 972, 275, 999, 639, 495, 78, 352, 126, 857, 956, 358, 619, 580, 124, 737, 594, 701, 612, 669, 112, 134, 694, 363, 992, 809, 743, 168, 974, 944, 375, 748, 52, 600, 747, 642, 182, 862, 81, 344, 805, 988, 739, 511, 655, 814, 334, 249, 515, 897, 955, 664, 981, 649, 113, 974, 459, 893, 228, 433, 837, 553, 268, 926, 240, 102, 654, 459, 51, 686, 754, 806, 760, 493, 403, 415, 394, 687, 700, 946, 670, 656, 610, 738, 392, 760, 799, 887, 653, 978, 321, 576, 617, 626, 502, 894, 679, 243, 440, 680, 879, 194, 572, 640, 724, 926, 56, 204, 700, 707, 151, 457, 449, 797, 195, 791, 558, 945, 679, 297, 59, 87, 824, 713, 663, 412, 693, 342, 606, 134, 108, 571, 364, 631, 212, 174, 643, 304, 329, 343, 97, 430, 751, 497, 314, 983, 374, 822, 928, 140, 206, 73, 263, 980, 736, 876, 478, 430, 305, 170, 514, 364, 692, 829, 82, 855, 953, 676, 246, 369, 970, 294, 750, 807, 827, 150, 790, 288, 923, 804, 378, 215, 828, 592, 281, 565, 555, 710, 82, 896, 831, 547, 261, 524, 462, 293, 465, 502, 56, 661, 821, 976, 991, 658, 869, 905, 758, 745, 193, 768, 550, 608, 933, 378, 286, 215, 979, 792, 961, 61, 688, 793, 644, 986, 403, 106, 366, 905, 644, 372, 567, 466, 434, 645, 210, 389, 550, 919, 135, 780, 773, 635, 389, 707, 100, 626, 958, 165, 504, 920, 176, 193, 713, 857, 265, 203, 50, 668, 108, 645, 990, 626, 197, 510, 357, 358, 850, 858, 364, 936, 638 }; /*-------------------------------------------------------------*/ /*--- end randtable.c ---*/ /*-------------------------------------------------------------*/ --- NEW FILE: sample1.bz2 --- BZh11AY&SY???? mS5=O?OSj? ?-)??Ha?AVn??E?a??????.\?J??- !??X?b?U??Z?\j9h????4TX,Tq??\Q at b1?j??*?- ????U??OA??Q? ?Q?wpR?*\E??X???U"fb??}???+ ,U? ???@??j?t??g?(?^A1????O?V|zR?tV?????5'b\:ch?\??nG6P3PC?@?Em0?) 2#"hb ?adHI??H?Pc!$ H?AN??V??A{????? ;??????P?? ?2$?4CG? >?1????]*?M?,cI(g? ??^??/??O??m?????E??o?5?'????????????y kC*?:?S?i ??2??h?s??T\j,?n?Y??0?\e?DRV-?k[J??R????R???m?Q????I!h??(?*%*?Q??j4"?X[h???EjJTl?TD?? ?4TX???&?GMR?U??b?TF? ??aET"*1-??#b?Y*-b??(+G??Q?j?ZR?k h??D?X?J?(Q?R??PX?w?&%?*V?DQ?YKF?kEd?F?%`??-?%??E??eZ ???????????2?%??A?m??,V??R????)X???i??*??????V???FR??k}9 DjTQj??U?d? ?S5d?D??n? ???`~?S rqo?????bI?S?M at N????sv\8 at 3??8X?,?#$??B(?????aE???UP? ????XJ?Y"??*???? ??%???P?E?Q??`???,??b?????FD`'???X??!8?O????7??N'6Z???;^??Mn???4 ?y?s ??4?~?? ?h?GA9??? ???}4 ?a36e/?;o?U?!????s?I?$X"w?????!$???? (?e?F4?????%?f??????q1?!?u?:??$*\?tp???p?P?paw???i/?????)V?*?o;?s???????u??sv?J4 _;?t,????????A?NG?? ???"2" ?H,?s? |q'?????7? T?????w????K?s??q?O?????}d?h ???Jv??u???_I??d>??}??Y)%???7EP?>??4???n?^9q????|R?[%?s!&??:?I?L????a?P?????Z?I&?_.??a??cz???.??>??fflG`C??5!Z??Fg?_o; ??????G?H??re?T??? s????R4???????5???????E,??3??<tO??G?mb?L }????H?}?j???NmG??????,-S?#???????(???-+?R?U S??[(D???@?;z?????P.K?|????????????D?pm g_C ?P1{???*g???y???e??????i??=M?????x???g?8?+"?~r?{?????`.''/??R??G?G?<'??[??G???9d??,B?? r???Ajd?)??,???6??t^>?:?x???X??j8??*M_"?9????9q?m?????????V?w????>??Yp???$??kT??????????cb %?)??h?Qw?n?&*????G)!??RA?????C??`??UF??m???l???*1??`??7?O??.-)'c??????K=???~a3?t????$ :L??4? g?????O??6?31?k/:\?? ?s???Oy9??????0?Bd?a!???N???Y?U????I?H??/6eQ?7#??f??O.m?????Op??,?o????W ?`i?]6^?q????`?\?V??rt?b2B?????+?}? B?P ?(??{????0S ????C???rp?#?v\??#??Qw?B ??????????W???P???'e?D???j;?4????????akBE???+)???}?W???--Je??????[?7?)??d?Y?U?u??wG.?_?r5n??9Bs?????????`k%@-?kb???X()?V???d?"?H?Y ?k )`T??TB?cY ???diQ?0k$?$* aU??,(?T??E?) ??Q%lc*V?bA%H?YE????H"?DE?D%Ab?"?`e????/i?'w<,??;??????D??????aQ??'F0?b?w"???q???.v!???ue??=O-?`??V??~?0S4X?4?@qrU#  ???3???x?l?? ?u0??????,1??q?]?9???+{????????l?E?IS?x[=?????[?r?????f??y? Io???z??#???/??8)?????]??????_|_???*?n663s7>???9????[??c?????@-???B?o?&9C?)??dp?m??}?%??? ???x?????$?????&???n????|?S}"??F???x?O??????L??????T?^?.?J??????h??????B??3??A??8?E??'N?*??g!v=?/?"aB?D?]0`?????  _?????n????8m??????????????s?r?M????hG2????4Kw?gC??#lz-?f?X???n?1?????R??u??????|z????? ?^8?\ m?M??,g??????tvA ???^?k??????1?? K???r?U???Q??????6????}????&$?? DZ32R??????$2SG??????5??'??VJ????\?;G????@?E??? *"?2 "( B+77-?7WYYb???C?^???"?Cc??7??^[?????=?C]o?=?x??7????B?a????R?bmv?????#??;??????vfc????b??/???n?p?w????}???N?????1? ???J?W??0?0???Qj?? S??Je ??d?? m?p?8Q????????;?hr?f????j?>????/iM??/?(??`W??U???:W????E???]?K?? ??????q? e?jeZ2 ???M9hUE ?CE 3Q??Q????K???m?^?NY?^)???:???? ??IE??GQ??J(?T;?F0??)????e?c?? ?????a~?`?????_????>?;Bt??1?|y???T?? ?"?????l[ ???q?Q?Qh????q?n?q#??:r?R?3??V?p!?Y???|?:G ???????z?i??????D+???Z?????x??????R??0Zk??X???g?{$?C??H?Di0G??C??s[?M*? ???/@je??Q????P??pb&=ZhW????z????4?9?X??? !??l\J??>?????Bc?????^?-?m?6c? ?#?N???-2??8a:kV?{?x?W?]?OS8????=?f???????*g?|X3C??;?DIFRr?_&|&Z?9x?????Y?B??7'???]Og>;K??????,8?|??~????5??????L?S??????t??OaIgwa1&??^?????????????s?C?????????Z???Ad?*?K?g??N?ZO5?{#???H?Q?db@??????l??P???!E??????_VW?x?vW??W????y?????b??iv3?i?'o?e????)E???#8F???X?&?2'??C? ?&??V>- Bg&??)?j???,h?<`???i??J?Q)dIK?V"?|????G??u?#??\?[%9?*?k"??G???S???lA1?o?f?????"??$???-?F???f?`?C?A:=???bL8??D????d;t???HKY?Q???[???<??u??????v^?u?>f??&?X??"si??4??EcIy0V?(????@?+VDj}8Z)?N^??A?9M#i0?.???Bh??8/?0???e(?M???[????J)????{w?O?k?????? ??hci???("(??0DTTQt??8????V?????v?6?^??)??|t^?6??,?????^gk?(??9rI#?A?????IWiQ? ????Q?ka ?H????m?U?G?q???????F?????d ??3? !???|???9???????#?{/??8?????IQ7???????]H? ?Y??#??D??&??@??N`?????e?????{h^*??!??{????0?c?)i??b?c?2=#???7??? t1?u1??????;??,m"?????L?wk?' ???J ? ????Z??L?6?(?]Y?Z????,Ke C?l?;&Gr\*i??T????Kp?? ilK???I?[Z??'M?????O??Z?y?)??x|?Y??A ??8?(??KH?d5???u??m:??/?q?t???V?????v*?"??u???~u{C?????~????o????=?cE???-h?J*?I????F??k?`?{3?8???o???V??????/?T??H??Jf x???A *?^? h??=?K!{7"/Pw??? ?? ?H??A?h9??a??*?T-????G???|?Y:??W????rw???T?h?????,??Q?+:?6Y???2?,!?? e???)J?S?6???16?????N?????L?T?$iE?nBh?@?'??c?o}H??;??b?f?s?`?????r??&?l???l???/C~2??|?0%???='?t?1elqF???mO??1???NHr???"!3???O??V???r??i? ?{?? ????EI?nt??????OA????-?sE4?\????B?????#??}??L!? ?D???G???/T??? ??0Q??)???? ?=&wJf{? C ?NUU|nz?OR? ?v???=?U??i?K>?8?_ j ?ZU???(??e?{???Z ??? 2??????M???;_Jfn??^m(9?&????n1C?????K?e??S??????e3/???Y?/0\_'/$Q? ??5?K:? ]??:? &???|0?&?lU"k?]6?z?q???s?R??"??$+??T??? 'r???.?????#?RPu+?l???$??n??m?oj?????g< ?0??:L?R?Ls6f?V2? 9 Yp ???J8?????u/u?@???????=G\?M.W!f???M?-?PnT?v?,?q??d ?Z2J?U??5??[?h?jSae ? ;L?????0??2???a?a?~??q7?? ??L?u3?}?s?t??E?V^v-nw9?L?y?a?????vg?|?q?????8?N?|'g|??r?9???????????\?. ???>??E-??X???0?'??F???[?Z??Q??w???b???B~-??;??????b????U??s?3?v?u??m??W??IZ?)V?7??Mk????\/????4S?C?U?=e?b??S???}??=l@??????/??7GD?C?x$????@??>W????m????)`??O??u?H?????????U"???<*?5m`???+'?Z/H?(aK?P????&?C@I??x?a????J??B6?C/.?j?(B???LQ???]?(????il +???c?VV:??$c ??,??????D?,!?lq?{@D?ng?T ?4-eB@?-?8U?x?.L?(k????D01n(?b????"fw??gcJ?4???"qA??h???a?@?Z ? .(+x0?p???,?V^??????u)?????afD@[-x?j?p? Q? Z???? !B? -?????(??B*Z?E???$?- ?r?6????50?T?*a?f$?IR?????C5???!sR?l????????$?????,??L?4>,???jk4]]GBKP?! ?y?*?r BvWk???!R?????6`C@oD?6ef?4?B? K???'?j??E?\?Q ? ?HpHh VvJ??|?????`????+k?V?E`?xzz???4j?N??{?+8N ?a??x??r? ?S???5t???!??????n 1|kX`?[Dr??^?4?U at 4?Aed?*????;????*??{9???;?gaD??N?k??E?h?03K???????&j???"??S2 ?(m?1???"?????nkI?k?I???W???V??H(?????J???\K ?Z????%???|C???|?????=?vv??AT?=????e{? '??y????G6???5T??'??_d??????Lr??r1??Et?"=l?A+?)??N?s_????;?R???????s6?;??o??p???}3?D7??]!? {. ??????0U`??F,???aRJ*9?d???$?????{?f&?b?Q$$HEBH??*??????P?6?z???`$? hf?0fpmY?5?b????PR4?[??d?e??d??x???i?d????! ???AX?$k??+d?P??v????????d?=? ?@????"L?z??????X94??$}N???E??H??????PM??n????cR????:'??$? tb?Z?4ZL;t?{??v??? ??????r??8.?????ju???}.?{2???o}???S???? ???????M??E? ??!kM??'?e?K\??Ffk?????? PHL?|??&5?K?=c+?^R?:K?Z-SNe??E????????y??`?%???????cJp?|*J??V?????`?ZB2(w?&????fZ??%? Yz?=???x?Y????R#?os?????/?h??????*???7?J???^ ??mQ ??6??J? ???p??v?7???q?n?W??g}?"??????j??i?3aEOK at .??q???&??p???????A4/n@C??????wj?[6{?? ?????-pi???F8?/wU??E????5???m?????L??%>>?ly.?R2*?P?tVa?p(?u1???' iB?BA??th?.?????c????? ?^??[ui??n?-nl??L*??P??<(_9??? +??::???Zb?g?~-?YV??iY??,K??? ?a ????a?|????t?? ???f????=O?2^q?j??????B?'?*??????P????\ 8D?U?rC1???K?U/??b?~#]f?b?7??^?E?'Qz??2?FSJ/???????a?U`?;T?a????_?????TA ^VsJ?+?????r????Z?u7??!??_-????F????m ?< 9?~????3A,?0Y)?&??? w??4?p?l )P?F???i6?f{=?4?R???xv??F?#?yk?4?0EfS^??????3UW?? ????<4?(??????/???????y?i??w|?K??[??B??F?????KJ?D?87rh^?d?0???HNF?C?Bg?;?y%???#4 `?? ??=?!??Md~??b?????u*?a?y?E?E?? ?#k /0?@?E?W??R ?!??v?**.?0m???? ??????? GP?xT?c ?J?2w?(?????? JH"R??*,?=????Q???m??KT?g???C????????,e?????<??d?RJ?D`???6?oS????kN??rd??n;;???\?? k??b??.=?."r2??j?@????F ???<)?? ??4y~Jq:??<}??oFPH:e5>B?3???X?Y??e??o?f???]yFzLR??1??l??2?K""?Y???3?k???!????x?V&?????\???)???@????61)?4?2'oe?Q????h~???@/0?:???\???a? ?EZ)C"???D??3T???UT v???4\? pB??CVTdV??X,?nA( nC? ? EB??X?LQ`?3B]L[K?'?S??FC??l?a????????e|?I???0O? #?P:h4 ?s(B? ? ?!?bTFZh????aii)d(??r??D?KJ?D?????:???????????????U???"<_.???;????=?~??=o?jo#g?r?H? ob???t?L??????G5??6????|?C???7??????/ ?l?Z??:?????????c}8??u\jEjm?? ??z???&?W????}??F]q'yl????7?uTNGmY???5?V???\??!?r ???|{?v??N???!? 6????8?qb?D??EXt???/7?????CK?5?(6??V???Uc ???BIF0? ??$?ke??]}???-[da$????>N??4?}?jNj|???fD?4aB ?"??;?f?`?? 53?" ?7N.?h ??{????g?=b??Q???*?O??BJ9??w?Gn_??t????}??B? L????Y?@?m???F? 8aA??=???DF?A?VL???Z\???&?j?v?tEp?ke???R?{??T?I???z??????{??O7G??VB?? :h???;?T??6??w8????{?????La^RB??* J#?U?????`6??M[????Au??????`)??-VZ?? )??'pd?? ?]?Pl??f??`F???`???x??U??(???>?h?H?]??Q r??Ye-e??:?????5?z6? Ji|-M?10?Xz?E?????$?O]?T?W si?.?N??yo?fV??Ib???0?E?{?`???VH?<{?Z?G??{?^_hm???????&??m0?QaF4?"fR?mJ?Hp??:8??m??Z???&y???Q???-?_ h??0?H?L"%?rlY??~e?>????T?F?{?3??]?S? Q??|1V(RJ??aRT?2???]?m??% ??E????s????2>=?kWr?Gy=?u?:???^D?^?w???r??u>?a???[?}/????'?'???U??^????D ?y?dQp-" ??Dzd0?? ?q??M?1?;???h??=5 at Z????????Yd?P:!???Z????`?N[???>;?>?j???!MII?I?~Y?"QV?<>c????M??K?????P?xi?Q?0??????R??Q?????G?Z??y|?{`n.W??z?T?Y??W??eN'????9????E?UC?????kT?????4?h??^??????"????m8?J?m/]?P?Z??U??9[??==?]Us????v?????????P8???/YeH?S* ??l?b#hvk?B?u????4?5???N?????wlT(?{1??7??O????????/??7?0??B??? ?????p???El&?uW?M?=U??D??????U?'IU? c?\~o??????;???o^??)U?|???????????6s? ?????;u?? ???n??`U??F??>N5?????0?m?F?M$?CY??D???=???k???$??????t?/???l?Z??S??I????5??!??O??&?&?l??+???-t?r?=?^????0{????@;???JY?RJ??q???A???{?9?O????????{????? ?V(I|D????FI???:YFR?% ?-'m]3q?? ???y?4[p?W ???Z?`?V n*'I??p??EB?????" w???HR?)??Z?? ?? ?(??$ ??^?S??!?o? N?,,(2???n?XrR??????B?$???1 ??A? ??????? ??Y ??E]???$z??D??S??S??DM???f1=L?????????P??4 2??????4r`D}???b?X??'??(??mJ??#????n.?? GAV?D????? ???n=?{?????5????3??d?5??B>??8??]J?(?F"??V ?ky-*??wlx?????_9 ?r????????U???#Q7???s1k?P?=??l?????{SV??IOuz???D)???? ????????n??'? ?`k ?????OU????????A???A 1?6??{??W?u????uUm? ?:V??06?????????????a??4?????#-?dv}??????8?????6|?????X?jU??m.?;3?3???0-w_h?K????D????p?o?P??R??i??v???5?"?;? ???+ R? i*_??J?p?n?}?Z,:f??W???? >O?Q9xs?/?]+??P4?p???]?[??SO[-?_?b???????-O^?N???LR??p?????)c ?ra?? ?re?Gd,?t??Uh???e?exi?#?s?t?in??rg?graph??G????n??j??i?#?s?s?1?e?qarc?h?e?Gd????R ?rt??Ue?Gd?in???t??ro??G????n?+1?????.?Th?e?pro?Gce?s?qs??9rep?#?e?a?? ?reup?Gon?UU?G?(?x????init?? ??)?d??Teliv?e? ?r?s?t??Uh?e?require?Gd?v??q?alue.?As?an?examp???le,?cons?#?id??Te? ?r:??+D?????????? ???]??? Y?????? ?(???),?w?e?h?a?v?e??G????0?????=?%_?f?(??lift?? ???(???)?;????>?)?g?.?Ev??q?alua?? ?ra?? b??=??K?f?(???;??????)?;??(??lift?? ???(???)?;??lift? b??=??K?G????2??|s?,?so????R ?r?w?as?obt?ain?e?Gd?b?y?ev??q?alua?? L????? ?r??6fu??rnct???ions:?high?e? ?r?ord??Te?r? xp?Goin???t???in??rg?w?ould?require?compar?*?in??rg?comp???let??Ue?fu?nc-?? ?rt??Uh?ele?Gs?qs,???b?y?ext??Uen?din??rg?t??Uh?e?not?ion?of?d??Tep?#?en?d?ency???b?#?et?w?een?inpu??rt?? ?rguson? an???d?Hugh?e?Gs? ?rali?#?s?1?e?Gd?MF?Gs?t??ro?w?or?? ?r?T?ord??Te?r?cas?1?e,?callin??rg?t??Uh???em?concret??Ue?d?a?? ?rence?for?high?e? ?r?ord??Te?r?an???alys?#?i?s.?p?F??*?e?rguson?an???d????, ?re??P?(++)??i?#?s?t??Uh?e?Hask?ell?li?#?s?t-ap?p?en?d??Po?p?e? ?ra?? ?rpret???a?? ?r????, ?r?s?algor?*?it??Uhm? ?re?qas?wit??Uh?CDSs?compu??rt?in?g????, ?rmin???e?t??Uh?e?en???t?ire? xp?Goin???t?of??concat??t?ak?e?Gs?t?w?o?or????, ?r?s?#?imilar?circu??rms?t?ance?Gs.?F??*?or?more?comp???lex?fu??rnct?ion?space?Gs?t??Uh?e????, ?rence?UUi?#?s?ev???en?gre?qa?? ?rwh?elmin??rg?p?#?e? ?rform???ance?adv??q?an???t?age,?it?i?#?s?t??Uempt?in??rg?t?o?for-????, ?r? xp?Goin???t?in??rg?s??Tc?h?em?e.?Y??*?et?in???t??Uegra?? ?r?f?ram???ew?or?? ?re?are????, ?r??,MF???G-s?t?yle??, xp?Goin???t?in??rg,?p?Go???lymorph-????, ?r?UUwit??Uh?MF???G? xp?Goin???t?in??rg?in?t??Uh?e?Glasgo?w?Hask?ell?compile? ?r.????; ?r?part?? ?r????, ?r?n?ee?Gds?t??ro?kno?w?t??Uh?e? xp?Goin???t?a?? ?re??x????3?? ]??v??}?x????1?? ??an?d??x????3?? ]??v??}?x????2??|s?.?Since??f????i?#?s?monot??roni???c????, ?re?o?v?e? ?re?Gs?t?im???a?? ?r?t?h???e?exp?Gort??Ue?d????G?,?t?h???e?b?#?et???t??Ue? ?r?t?h???e?e?Gs?t?im???a?? ?rh?ap?qs?a?h?an?dful?of?p?Goin???t?? ?r?a?que?ry??*?,?it?i?#?s?ext??Uen???d??Te?Gd,?in?t??Uh?e????R ?r?:?d??Te?Gs??Tcr?*?ib?#?e?d?a???b?o?v?e,?:?as?require?Gd.?If?t??Uh?e?a?b?qs?tract?in???t??Ue? ?rpret?a?? ?rf?#?ace? le?Gs?m???ay?not?b?e?pract???i???cal.?Thi?s?s??Tc???h?em?e??/also?h???as?a????R ?r?refe?rence?Gs?an???y?ot??Uh?e? ?r?equa?? ?r???t??Uh???e?fo???llo?win??rg?t??Uhree?mo?Gd?ule?s???d??Te nin??rg?recur?s?#?iv?e?fu??rnct?ions??f?,??g??an?d??h??wit??Uh????R ?rf?#?ace?(?.hi?)? le?Gs?giv???e?s:????a???F.hi:???f#???=?...?f#?...????a??G.hi:???g#???=?...?g#?...?f#?...????a??H.hi:???h#???=?...?h#?...?g#?...????R ?rf?#?ace??F.hi??ev???en?t??Uh???ough?t?h???e?t??Uext?of????R ?r?t??ro??F?:?in?gen???e?ral,?it?migh???t?b?#?e?n?ece?Gs?qsary?t??ro?re?ad?all????R ?rf?#?ace?Gs???in?t??Uh???e?do?wn?w?ard?clo?qsure?of??H?.?An?y?s??Tc?h?em?e?whi???c?h?exp?Gort?? ?rf?#?ace????R ?rence?s?t??ro?fu?nct???ions?in?ot??Uh?e? ?r?mo?Gd?ule?s???su e? ?r?s?t??Uh???e?sam?e?prob???lem.?M??re? ?rely????R ?rence?Gs?t?o?ot??Uh???e? ?r?equa?? ?rf?#?ace?Gs????R ?ryt??Uhin??rg?b?#?elo?w?t??Uh?em?in?t??Uh?e?hie? ?rarc?h?y??*?,?an?d?h?ence?v?e? ?ry?large:????a???F.hi:???f#???=?...?f#?...?????a??G.hi:???g#???=?letrec?f#?=?...?f#?...?/??in?...?g#?...?f#?...?????a??H.hi:???h#???=?letrec?f#?=?...?f#?...?/??in???? ?in?...?g#?...?h#?...????R ?re?s?1?epara?? ?r?n????R ?ren???t?ins?t?an???t?ia?? ?ren???t?ly?ins?t???an???t?ia?? ?r?on.??Q???, ?r?ap?proac?h?i?#?s?t??Uh?a?? ?r?of????, ?rt??Uh?ele?Gs?qs,?su?c?h?b?#?e-????, ?r?of????, ?r,?only?s?#?imp???le?li?s?t-h???an?dlin??rg??fu?nct???ions?lik?e??map??an?d????, ?r?of?ins?t?ance?Gs,?an?d?su?c?h?fu??rnct?ions?are?oft??Uen?inlin?e?Gd?b?y????, ?r?s?an???yw?ay??*?.???So?monomorphi???c?an???alys?#?i?s???m?ay?not?act???ually?in?v?o???lv?e????, ?rv?e?also?t??Uh?a?? ?rpret?a?? ?r?*?ious?i?#?s,?once?again,?t??Uh???e?in???t??Ue?ract???ion?of?monomorphi?#?sa?? ?r?an???alys?1?e????, ?rv???e?Gs??[all?que?r?*?ie?Gs,?ev???en?t??Uh???o?qs?1?e?f?rom?di e? ?ren???t?mo?Gd???ule?s.??[W??*?or?? ?ra???b???le?d?et???ail.?Baraki's?w?or?? ?r?fu??rnct???ions,?p?Go???lymorphi???c?t??Uec?hnique?Gs?giv?e?t??Uh?e?sam?e?re?Gsul??rt?? ?r?ord??Te?r?cas?1?e,?accuracy????, ?ren???t??Uly? r?s?t-ord??Te?r,???t??Uhi?#?s?m???ay????, ?r?an???alys?1?e?Gs,?t??Uh?e?m???agnit?ud??Te?of?t??Uhi?#?s?prob???lem?h?as?y?et?t??ro?b?#?e????, ?r?? ord??Te?r? xp?Goin???t???in??rg?i?#?s?dicul?t?b?#?eca???us?1?e?t??Uh???e?la?? ?r?o?of?t??Uh?e?sam?e?t?yp?#?e?giv?e?Gs?dom???ain?[?4???!??4??!??4?],?o?wit??Uh?24,696?p?oin???t?? ?r?700?t?im?e?Gs.?Th?e?n??Uu??rm??|qb?#?e? ?r?of?p?Goin???t?? ?rt???ainly?v?e? ?ry????? ?r?s?h?a?v?e?t?yp?#?e?Gs?more?comp???li???ca?? ?rm?rewr?*?it?in??rg?som?et?im?e?Gs?f?#?ails?in?t??Uh?e?pre?Gs?1?ence?of?fu??rnct?ion???al????R ?r?s.?? In?t??Uh?e?gen?e? ?ral?cas?1?e,?high?e? ?r?ord??Te?r?equa?? ?r?s.?Th?e?usual????R ?rall?` xp?Goin???t?b?#?eca???us?1?e?su??Ub?qs?equen???t?ap???pro?xim???a?? ?rm?in?v?o???lvin??rg????R ?r?ap?p???lie?Gd?more?an?d?more?t?im?e?Gs.?Thi?#?s?o?ccur?s,?for?examp???le,????R ?re??E???i?#?s?som?e?arbitrary?t??Ue? ?rm,?an?d??foldr#(n)??an?d??foldr#(n+1)??d??Tenot??Ue?t?w?o????R ?re,??f??i?#?s?a?fu??rnct?ion???al?param?et??Ue? ?r?b?#?e?Gin??rg????R ?re??Tb?y?m???akin??rg?syn???t?act?i???c?d??Tet??Uect?ion?of????R ?rm?rewr?*?it?e? ?r?i?#?s?extrem???ely?clev?e? ?r?it?can????R ?re??Tb?y?gen?e? ?ra?? ?r?#?n?m???a?t???c?hin??rg??pi?#?s?tr?*?i???c???ky?{?not?so?s?imp???le?for?dou??Ub?ly?recur?s?#?iv???e????R ?rms??_{?an???d?w?e?n?ee?Gd?t??ro?d??Tecid?e??_on?a?suit?a?b???le??n?.?Th?e?v??q?alue?of??n??d??Tep?#?en?ds?on?t??Uh?e????R ?re?Gs?t?im???a?? ?rt??Uh?ele?Gs?qs,??for?high???e?r?ord??Te?r?equa?? ?r?s,?t?e? ?rm?bas?1?e?Gd? xp?oin???t???in??rg?w?or?? ?r?t??Uh?an?us?#?in??rg?f?*?ron???t?ie? ?r?s.?Su?c?h?equa?? ?ra?? ?r?argue?Gs?agains?t?high???e?r?ord??Te?r????R ?r?of?d??Te?Gs?ign?con-????R ?ra???b?le.???Can?su?c?h?a?s?t??Uep?b?#?e?jus?t???i e?Gd??W??*?ell,?t?ak?en?in?a?wid??Te? ?r????R ?r?ord??Te?r?fu??rnct???ions?d??Tefe?qa?? ?ra?? ?r?s,?Z?s?ince????R ?r?comm??Uu??rnit?y?go?t??ro?cons?#?id??Te? ?ra?b???le?trou??Ub?le?t??ro?get?r?*?id?of????R ?r?ord??Te?r?fu??rnct???ions.?F??*?or?examp???le:???????X@?{????c ?r?s?alon??rg?u?nc???h?an?ge?Gd,?uDlik?e?? ?r?s?ions?(in?Y??*?ale?Hask???ell).?? E?????2@?{????= ?rload??Te?Gd??efu??rnct?ions?are?sp?#?eciali?s?1?e?Gd?a?? ?r?s).?Thi?#?s?a?v?oids?a?gre?qa?? ?r?uGord??Te?r?m???ac???hin?e? ?ry?whi???c?h?i?#?s?oft??Uen?as?qso?Gcia?? ?rloadin??rg.?????, ?rm?e?Gd?? rsti c-????, ?r?ord??Te?r?fu??rnct???ions.?Al?t??Uh???ough?con???v?e? ?r?s?#?ion??lof????, ?r-ord??Te?r?iprograms?t??ro? r?s?t-ord?e? ?r?ii?#?s,?in?gen???e?ral,?imp?Go?qs?s?#?ib???le,?iprogramm???e?r?s,?b???y????, ?r-ord??Te?r?#?n?e?Gs?qs?83in?ce? ?rt?ain?idiom???a?? ?ry??*?.??DThi?s?m???ac???hin?e? ?ry??*?,??Dcom??|qbin?e?Gd?wit??Uh?aggre?s?qs?#?iv???e????, ?r.????; ?r?an???alys?#?i?s??Ah???as?t?w?o?m???a? ?r.?Th???e?f?*?ron???t?ie? ?r?s?algor?*?it??Uhm?ru??rns?re?qason???a?b???ly?qui???c?kly?for????= ?r?examp???le?Gs? ?rm?rewr?*?it?e?bas?1?e?Gd? xp?oin???t???in??rg????= ?r?cas?1?e,?an?d?doin??rg?so?m???ak?e?Gs?mo?d???ule?s?e?qas?#?ie? ?r?t??ro????= ?rali?#?sa?? ?r?*?in??rg???t??Uh???e?d?e?Gs?#?ign?cons?train???t?? ?r,???p?o???lymorphi???c?an???a-????, ?rpret???a?? ?rms???in?wh???a?? ?re?Gd?t??ro?b?e?an?a???b?qs?tract?lam??|qb?Gd??ra-calculus,?an?d? xp?Goin???t-????, ?rm-rewr?*?it?e??Hsys?t?em?whi???c???h?transforms?s?1?em???an???t?i???cally?equiv??q?alen???t????, ?rms?UUt??ro?syn???t???act?i???cally?UUid??Ten?t?i???cal?UUnorm???al?forms.????; ?r?forms?part?of?t??Uh?e?Glasgo?w?Hask?ell?compile? ?r,?an?d?o?p?#?e? ?ra?? ?rre?d?t??ro?as?Core.?Core?allo???ws?lam??|qb?d??ra?t??Ue? ?rms,????, ?rals,?lo?Gcal?bin???din??rgs,?on?e-lev?el?pa?? ?r?#?n?m???a?t???c?hin??rg??a(?case?s)?an???d?con-????, ?r?ph?as?1?e?Gs????, ?ry?su?b?#?ex-????, ?rf?#?ace-pr?*?in?t???in??rg?bm???ac?hin?e?ry??*?,?bso?ot??Uh???e?r?mo?Gd???ule?s?bcan?kno?w?a?b?Gou??rt?t??Uh?e?s?tr?*?i???ctn?e?Gs?qs?of????, ?rpret???a?? ?ra?? ?rt?y?of?t??Uh?e?ap?p???li???ca?? ?re?di e?ren???t?p?Goin?t?? ?ren?t?d??Tem???an???ds?or?\n?ee?Gd??Te?d-????R ?ren???t?*?concret??Ue?t???yp?#?e?t??ro?h?a?v?e?it?? ?r?t??Uh?a?? ?re?of?t??Uh?e?forw?ards?t?yp?#?e,?la?? ?r?d??Te-????R ?r?an?d?giv?e?a?s?#?imp???le? ?r????R ?r?s?sh???o?win??rg?h???o?w?s?tr?*?i???ctn?e?Gs?qs?inform???a?? ?ra?? ?r?sugge?s?t?or?imp???ly?t??Uh???a?? ?r,?t??Uh?e?cas?1?e?for?buildin??rg?a????R ?rpret?a?? ?rwh?elmin??rg.????a ?rpret?a?? ?rall?s?tru?ct?ure?i?#?s?s?imilar?t??ro????R ?rms?i?#?s?di e?ren???t.?As?wit??Uh?an???y?purely????R an???alys?#?i?s,?high???e? ?r-ord??Te?r?an???alys?#?i?s?i?s?imp?Go?qs?s?#?ib???le,?so?w???e?n???aiv?ely?as?qsu??rm?e?t??Uh?a?? ?rpret?a?? ?re??Tb?y?in?d?u?cin??rg?cons?#?id??Te? ?ra?b???le?comp?li???ca?? ?ry????R ?rv??q?a?? ?rt?ain?cons?train???t?? ?r?? --- NEW FILE: sample2.bz2 --- BZh21AY&SY|1?a????????????????????????????????????= ?}????` ???X??h?}?>??G????]:?U??9???K_??Qs??m?s??of?+?w?? F2?)??(?HP???N/?o?s?[????~>q?;|?/W???k?wRo????G?7???.?"s??#sA??w?[?x?D2????.???:??}?????3?????#????s??b???*?uP.????GR?kB???G.????wN?sn?f??????????:?;_j?y??????s????????rK?K??????????e|?D?,?????B?p5E???bqMp????q~??k.^L?" RDt?}?&???/?d?r?.? ??H[???)?G???? 2?Av???????y??w????o?M??-??t?OX??hEC;?-jVx????R???3?n?DA??h??>_;??>?"?7?8?!??QzgS+?? ??????C?[?DBq?-|?Y'k????0??4)?3???g?z#??.??L??h???-/???[?44?$h h?Bu?)?????1P}?CU?}?/pb???r??A???;|???????V?????_?????{????T)?P?T??????????/??Q????k\B?v?????:";??l?? ?????9??d?BJ?????A??o*?gs??Q?????I??3?Z[?M?Ur???b??{???r7??????? ?L?A,T??3???oYI????Jd?I???'7?}??????????x@"?.??[??6u6????R??x?,?[??vu T?G???i??a?N?????3MjPi?o????>?=????pDADi"??#$?]???????^x?/????M` x't???;?~-mW?????"??u??N?R???|????????05}??Swo???????H?.?$o???? ??????8l+? ?????? $^?x?????f?,v???X{w?????????S???l???K?Z???O?????!}??,s?^L&? ?????|??? ?????> ????$PC?????c?6\?Dj?5 ?le???RZIV?(???????8>?n|*?????u??z?h#?????L???z???Wo?V??(???h?X?E6?Y?h??1?g?S*???i??+'??f%?????%????|??yD???J?xE??(L??c????{??`X?'??/?}L?Q??})??O?M??J?fv???t?0l?)????jF???'>????FDEP???k??=C? ?:H?@!q)!????|?W??O+?Q8???$??F???7?????fP?J*??g?x??????N?Pa?? "??????????C???P??????????hK??+????Z??)%?? ?t-pW,m?Ln@?|???I????5???mvP???&&??????????z+??Uu??{???o{K???x??fH1??m?:`?RB?#;5??_?0% ??F?D?????'&DF 8D?p??????->?bL??YM?Uw?/????i{???)?JY????e??EGP??????Nc?*hS????^??D???????~Gf?\a?%???Oj?t??T@.?e??X|??j??X?p?kJ?}?O???.5|? ??F5wB?%2gwfb?/?a?s??z6_S?C?=?m??? $#?0???-???W??????? ?????f?~? ~????~??a3 ??F???du~??? ??dM???h??;???87????#R&>??????^??????"T@`$?`eY[n?J@&(??4?Py?^{??O#??c ? ?Y9I??V?U??6 ????0? vC"?qa???????7????N?????#b~?4???/^@??{??N?m???n??N]???$h??B??{?p???}Dz9???X???R? S??z???X??.?MA}??M? 4????/????}f????#??1?$9?!?r^??r??}w??k?1-!c>??j>??+?9?] ?|?????j?D???q#????????????6? '??L???N??W??!??2??{r>?????}+|(?L0???TS%/-?? ? ?8???0(?8NI?[0,U?w?v?o?C?c??,???7nn???LO^5??a7?Y??YE@@?5?D7l??v?>??6E?????^???V????m ?CI?;f?#???E??=G?W?q_??t?o????????5?i???q?????"!??~S??????????_}?X???o??x?????????|cM?~)????T?A???????k#?K?N???m?/?????????r?m? ?P_?]??=?xio]^??U?????p?2?gc????}?y?;nO??$sW{???y3??%??? $=?Y??????)???6??bx ???>2 ?????_???x??9?T 8I?? ???S$???~?GQmq????T/ ?^?X???}???b???D4??????ac.??=?:?{???o+??_?????)?#?X?eg?t?t??????~R?_?(?Z?]E???aBD:,???????:??????????7???0??]?o?, 8A?^?h?x? ???u U!????,??cWy????U?@?d??jDd><>~? U-"??j|?.? $?(?? ?,E'???T???????d???YD?F;????????~}A-$Uw ?r?????{????J???hT?m??@Z ???($?JW*??? n^??7s5??? !5`?????eT[?*? *???9?{>???]>Q??= ??J?E ,?n?k?cl???U\Wv?kJ(??A???N??c?F?;???i??B,?}? ?r=?K????;????? -??}????@?T?7?R??=??|???_?????u@?B A?%0R?{y >6??=_/??;z????PH R?D?ZP?I&~?W??o??Cm??w?o??`:?????=?N??????66O? ?????m?????5v??^?????5??0???x??*??????#????C?Hs?E??3????Z????(O??a ?E??5?? U???'?2[:- ?????H?ECH< ?w??a?? ??D?'?????i?????O?s???1??z????E??[?g?????z?4?]g????%|W{[c??0???????????>?G??1T?$??N ?3?Q??("??P?2??,M??=r?k?Wu?*J^G?k9?u(?P?>=?59,???_/7?{??z?????????|L/'????3???????s??0NKm??-@?????=?wpR????+?'??U??~??n?????|4e c$1 ????-??fT0?C?Kl?? ??????>?r???o?? C??x? ?7?n??sR??l|fk?Rf???{r.t??x? ?-?xqA?D?}???R??????* &&??? $?-ej????????????@}?|???????RB.??x?`5 ??????yDj!Ax?i??)?p=?+??*?c19??F,>???A?`?T?Kl?.?3,ys??Q??|?d?'?#8k??{???J"aG???????a?~1V*C(??m$?Q?T?R?}??Q[5@??*N??_Y0???B?t?Na??q?,h??e??????*???????r^?!??Y?j??9hh[yo|????x;?pllo?Y?????~????5??>?5 ????"?5?W\?????M????g??U ?YV2Z0)|P3lR?h? ?\?????c ?D???V??$?6?2?A?%t?kF????????{?w?? ?m?&??a?^.??]xw9Q?`m?\????Hth--?VF??/???J'?DVCC??$?N?O?????? ??'s?7??7???c>??????3@|??IXQ?y??????m????????Z?iO9p?!????7???IB I?^??7?_{U???$pp`f? ,b????????T?=K7?G! ?E=????X??P??Uz??!H*??.???D#W?B"??(w? ??k ??ns_?5??M? @RJA?m6}?^?g??P??3?g????2???????????!??@_{\.B?o???7?n???s??[W*5?%o%?U?W*?0??G???$??e???r2G?J?Hw??b?8????F?m??,?/3?vkbA`{S??z??>???l*??[???N1k{???????jfL??vwd???t\??4?ri? *s?1K???b?????w??? ?? ?B?C[??D ???E???D- ??``sg????????`t?Zz,????????(SL???5??b????~_[[T??~?od???m???????G???Q0????n??*??=?Ou?????_8H?S?G????? Cg7???v1????%%",H??e?WS?ds???E??Ad?$??Y??LO7B??{4???c$???yl_`a????~??y???(??&???^?Q?? ??!Q?)?^?W??6?????w?????+JT??????[f?NC}???????d=????c???jY???3???G???)??????=Ny???G?SU??=???L!??}??wS?? ??egu???-W~????Z??p)?|,??5?CT?FA$$:L)^jFeUq5??W?5C?f`?M????y7Bb<^??i??@???8?S?y2??3~?pI?1?9g?|t??}?c??RZ???2?? ??W ??M?W]??????a`5?gC,??l? t3G??g?Y'??U?3???`?I?????Tb???9???j:??c??????`??????]??P????hcM@????????3?4Kk?=?4???7??b{??$3.? ?;Yui??f??r?Rp(???7f???+Fl>?d???????~4?9??y?????P???????g????????????i????= a?\??n?*??? G???????L?F? >???W?C???w+??=????k?*X?V?? "?jQ???Z?$??E?Pw???L?????|??~k????R??j?6  j???Bc?e 1"E=R?b?M?`T?Q??G?d??;Ze??S??"$????!?h? ?(b? ? W?SZ?do?m?xg??RyG?\???'???z?x3? Uue? ??x*????P5R'$-?Co??A&????7i???j????6e'??wX???Rm??x|?7$^??k?r?gY?u lKIO???k???;}?\G??^eG??qYY{?v????? {???_????&?y??Jv-/???i?????3??J?yL????V,A|???K?-r???2\???H?:???',???7?" #t??g6s.D?????K!?m??T???????a???u???6??a'h?{bN???fQu&?$?L!??" tD??Nf`??6f?@??f"`??(/e??c?7`?=?????P??? ???^u}u????????q? ???6??5????&q?0E+|??????(???G?'_H?{?????E?q?????;??R?u????^j??y??$??O?X??A#??Z(???-????????????b?7I???S??(;(?DxH?????C?k *?>?d????v???@?"??z???~|wS>{???A???o=?g}5p?????I???3~?0??tpN&<&J?&?~??K?????Q???&>???J??????v?F\_??j?????*???~??m??h8E?h??{)"?????+?ML?)?A|?B????????v@?)(???n???y?"??F@?I???!?q(O^+?H I?r??? ???^???4?V?f+?CB??c?0j&???T??? 6??= L??????qk???Y?kmh????KH? L?Z5x??0?#?m??SyP?B???%?t??(????T??J?>'%?c??? ??xYEi?S?7$???y|?!:?????C?8b???@??l? vj?????YE&????? ?? -_?b????Cl0??qgG ??A?EBk????E??1H$w ????Z?????K ??v?"???8??Od?f??3???j??a' c??.; g?;4??????=`??????>?J???????N?[i????~f??M??]'???l?e6???J?? ??Ly's??~X|LW>^??A??j???w?ob???Q???W?o:?Byx??h@????r?g38L????L???+m?i????x?U?lI?}?'3 8[Z?c???wQ??8b??DQ??4?B~ErC??mP#???L?L??o?n???T? UDDb ????)?w?r????A^???k??????T??+??#leu?0hc?A?lGF?d&?h ?? @ ??tUG4?L????????0????Z*B6???U:?e???e 'X6???$?Y??? `??$`?`??Z?/??_?????4????x???~?{??L?? ?C?"5'?p?????/ ???g0?:??????????@???7?\?`t ?g:????l?S#?+?hew?zH'?D;?3j#r(?pCy` ?????3??%?dL?????6N??s??Mon~@?&????7??R2!???J??C?kQ:k???(xj??r?w??M c?/v??3????k?'-r?W?????Yz&????!?C???x?I????VuX???u??_K?30?ov???_?{?$LK??rk????d?????L???Rb?.? ?~a?e?BZ? ?z?YT;D1???l?????G'???G????'P???hL`.?"`23??wvrv?&N:jpc?QL9?F??=,??????.??O??P???=^=N6tRR7?I Y??]??Z:j???I?n?? Yu??q???u?????????>??_?r???-~??]++???X*?=bx??????????Y ????-cB????uc?|??HHC?L????????H????j? ???uF(??%??fWg?3??fx'[?]%?????x}???? ??x??R?U?k???'t????q??"?N:?g|?jnn? G????????q8d???.9?r? ???(??&??" ,?U?y?U???6*??]5?o???????L? 8???hG[?P?G?jE$?x????b#w?S?x?? ???H?HY??M57?????%??f.B?i?Z????oX?X?3?$Q?(?mD?V:*??5?E}???? ?????????????g?v?)?j??vQ????z_???????A'?3?6u?7????K?O? &?N?{?????N??:,m?8`?VP???;?????$h)6W/\??y?^9? ??~?N ?*??T???Nh`E?,u?h??C U???pP?&ue?????????8r'??NpQb???? ???5aH?T(??h(???8L?}NvZ#??Z=?8????i.t?s2?????? ????B?6els W,?$C??I{'?`?]<+?G???Cv????!O UI??^!??{??K???vZ???_ ???n?w s?.????q?t?7????????????n???#m>O???7?H???5?>???'?`?G?)*?&??D?? ?X?&????b??w6??? *???Y?"??7,? 5/??&?? 'H8??? "I3r?? ???\?8 ?":!?q@sk[dY? ? s????M???7????"e?4?????0s][????L?c7bCXpA??0??????????V???????f????w????? ??f d???YJ!?FK?Tm?M??}?l??Sd?e?6?x?[? ?/?\?6?V?m???3?8x`+G?g3k?? &?Y-?k ???r?M??0???j????? I??????U,HD6Q\m1?Hq6z? F[?????"S??&?!\??33+?????+??)i!?????"Z??S??l?kk?!??S???9vj4h()??a? ?`?fM?km8?%?k?ZMc????e? h] ?? ?\?????50????R "???lZ4[TZ???????[E?j#j6?lb???I???A???(?%??E???Z?E?mEZ???lZ(????iF h?(?FH?I ???BbH"K(AB {???? $??E ?33)^?9S8???u?iXa\^Z6?d?b1 ^6?R?%M* q ?F??????V?"4%E"b,X???E`"??dEEA??cn?&??QS?~@??Y?? ??L!C$D ?d 3???#?????XS/?;?d?F???bB??,???cX?{?>W??????j???_ +?i?2???P??F1?G?# ?v????????H6@cCC??Tcn?e2I??L??u??\r)6??#XJ?L?? $d??2??:?iIL????U????????e?||????.?"%c??ZK#v????nJ?6??rI#H?? D2y4i????4??^N????_?$v?{?\???#??????Z?Ct??KP(P?iPb;???U"4?JU{S'????=???72 at PX}uM8?d??J (@D?J?#?L?|???3??5R:J?c? ??_???~{fA?#???h???j??l"???kb?$?Tm&?6?Z6??Em?l%Th?j4Y5Z+_??$7??cQ?-?T??W#b?F??b??RZJ?_R??b????q?????&Ja??????g?????????:2?JA"a???? ???y!?4N?*? r???%b?]0?H ?o??kF?????C???????Q?&t???~?pf??X;DAW???n????Qv???CT??F?.??'?h?6??????V???????,???S???tB??H~RZ??^??p??]??-W??5?\M?{?+[~?i?#L?v????9??l?|. ???=?M\???$`?41T;h)????Wq?U????_???o???f?.???h?L??? ???>?#?'?S???? Q??,?h????????????FiMT~???=???? ???D?w???\?_?h??'??(??Z???????C??h?HB?O??e???& cdi???76IN@??v??????Q???0???v??????????/]=k????k'?? Y???? rHc?757v???0?b??C??"v2????7?Z?KI"???5Q|????*??9?B]?'/<]x????????3?? ???_^??;C?D$.?hG??a??`e??(4E?DP?tkq????5*???????????K??_???a??L????1?W?????okL7???` ??p?~?l??oq???[??[Xc&H?e???X?|?TY?kx ???i H9]?'?D??9???g???/??????yn?j?!?"R???$lc=5?U?g??L? $K^M;sPF ??k?7??????????????????dFP??9XQl??FI??"`??(??Q?????DF?Px????1?A? "??:??????w?; ??P% ???g~??4??? H?'zN=???; ??^8???$QE?1&???^???i at AX" ??IX??8?f???G????N?:???????9 ??a(???` ?eBZ$?bU7??~J?? .>a???^? 1?????z??????`?/??0L_?p ???Xx????on?#F??r?<[{????s????$????x?k??PE/??Hf??d?80H?????? ?b ,???)?S??|x????X_???+L}8OT{??6???5m?1???CyedjB?66???U??< 76???,z?\+?T????dlM"0 ???x?y???`?S??X ,h????? ??F???^????F +7?h???X86?"?!?? K?\j?lV0?3'%?cI6?+??'t?]?%??[???su>n??F?y?\;j???1?U?????,??U64????(W??????????u??Y?3!??????VA?1??i??F?[???I????aFA???*???? ???9*?a??L9n?e?????v???Z>???A?m?0??4?????q???z?????8??.? ???? h?@???o6?W???? ???t?6???i?"ad??*????A@!.??L?KC?!??"!9?Y??o`??E!?????a??.#? ?/??:?$(?n2?, ?@P)%"<?_9q$L???(?)"1?$c"??Q?Jm0?t??(Z?J?????Z???kw?]?c??$?qaC t?1jRdUu??????T?????.?Q*t???}"[?d5???k:?|'@?qJ?x??Kb{? #??7???j???s*??H^?g{??E;????E??? ??????6??]??????f?^P?: ?*z{???]s?*??!?X?`?e??????YX\)??fL??E&??Q??3A@?! ???????@????{?? ???0?0?q???????[k??S??U???v???(?y(9??]?i8??$????7|WGK??S ?qZN?r?M?CFNR)?!?? ?AB???1.??R(S x???=?Lj?bD[??$?@?@?x?"? `??3 ?,???&?\t?*?????????E?!U?;?&?R??SoA?jk?}?????8?K??????l???P???????B$?&G????M?p????? ??????5 P????x?S?7?(?u????!?8 ^?&? ?????S????????^?@?`Z??hp?????:???Wu??\o??????C????$1??/B?ew|??r???????|???=???xK?\?p??W8D?????W{?T ?r?- _??\????x??v?? ????$?C??D?8?y?ON~\?q????{?b ??????v????e??\????!m?,?9?UAH?"?rq??????=??????g??#8x??s??alF,C??|FF?y?nO?{x???$?J(*2C?:?"M??A?-@? 2??@? }L7?t^9G[???hD??A?p?St???n?*???E??J?????@??e????;(h?p???+?(?cegb?I.????'?z?5??????ma_??_"???z??????????????L"j???}?O???@???????Fv5[??k?b?)?j?hk}M???I???O?5???#l??*?lM8?j??z????$pE???KiE D???|F+?O???]?r;??&R?DY?n+?g1?????B9???Z=i???[V?(m????.s?'Ta?C%???Lo~?+????CE L3??M?P,?"(????, H?>K??r????*???Emu ??o?[r 14?i4X?t?JfP???~a??F????o? ???T???-BE?D???r?oj:? h?0??G4?m5?$P?M?Az?!?2?????` c????????^?^:??jV???????\(b I??????Dj????|{??r?!nn?1z???*5v?)???????j??rwI?T???w7Z???) [? MWo?Te?%???=l?????GB}??e??3&nqA\&??kt??????Jb/_x???66f*???????cn[???0??$?s??2?j?1???(1?TZb?:)?????????=FZ??????c???R?FH5 ??{k?^?????^OK??????+m?ns\?s]+?n??????tS-?&????6??k+?wb?,?P1?v9?2???UV?????&&????????? ?wH??R?0?nv????D??o?J5??6?????G????~????I?w d at 4????e)'&???:?a ?!?E????U??#?b???'???4UI G??t??7WW0???1-v?@cN??I????0? Iu--)4?? ????\???E?9Q?F&???? {?D?.A??]??L^??$???1j?g???????/p????%? ?]??%E???KAD???2?@4??l??8??Y[?8???????X#+???W%??????>????????F?d^ ??9C &?_???GAzy9=?????|?>[z ????V>R??W?'b??<-??;?? L??0????????w??e??74Z??'???????U?m???Y?R,8???Yq*?Dj?C?4r0????? ??,P????????'?3?????`?W+?????xPi?c??n?3 "i?LQ?+??haw!C"???\5?*??l?)?? HwP? ?sy?.???e?u???94??e`?r??????Q?? 8???c???=????Ko?????? ??66?B??&?1?[5e?b?i4q?nbs?Z?j7q?X????????R???J???M8qc??(???osZ????x???????Y?? ?V?a?????Zu?$??.l?????^?6??#??d?U?3? p?7? ?+;?????;????w?Z/?????R;??2?2?RP?u?????0f8I:5Z|l9?=D??6?u??????mh?mno????@??? 1?}??L"?+?????K?K?SB??Z???i=3I? ?u? ?E??X?|,?]?????{d_?]?d.~?????i6N`&e????^????U?0y)0FX;?X/s,.n????M ??=\ ??r?9?h??P?L?0=v?rbQJ"^??? fS ?]?$C??9zym;Ie?????M??=p??????2?,??6S??? ?>jB?hZ,(?C N????W]?????8?????pA????1? ???????f?I?E?l2???H\? ?Qmm??Ul?}?=)1E(*?5}g???^?? ?cF??*??(5M?\? ??? l?x?????P????a|?-H@??F????P?h??;u???P??O???*???a??;Y?2?[?#??Qwt??8H????DV ?>???????w?????*?0 ????0???|?6b?y?D??U????2C??#??? a?6????V????????? ~Y????9"???????????t.?????=?P~?????yH2.d{? ? 5?m??????oO???LTM?85????#?xO^+e?|?l?*?):???3K{??X^11?0xv9w2X??=? ?Q?8?? ?]?????/  V?l?"?A?}R6?'6-fs???????9N?sUyO???^?AH^?.??u??u'w $?i2CJY???[???^????????x?`?o?]?!????e?j?|;N?1\???$G??Q04?a???UPx% S(??????zY???W?p??y?!?la"Q??K3?Y???7?`? ?R27:7H??i?eDf???V??r??Q???g0, ????\Q????`1??????`??kA?ay???!?HBD?M? A?cL??k???i?=y????=?n1????VA?8]9?\e??P?Ne?9????b>?7???Q?)? ?G??I ?,APr??o??????s?y????J?{??vQG.G?" ?????Dd??????`???gH?Y?o????? SS>??e?Cv?$9x??y?'??/???uT? &??>k?????!?,?'?X"? ??Z%???l%?'???????[dF??3??]_"/??zX?pPq?? ?I???m???Q/???g?? ???)-)?M'??a?H !?????????d??}?W??2? ?Dq????!4$v??9@??U??iL?eB0?]?{; ???V?u7?[??ve?M?V`M?????? &?e?????`M^??\K?!L???? ?Q!??0Eg???S[Ww?B???O??bKP?SE????p?1?B`$?$?2A?????3?g? MJ?"????????5??n7?????A?( ?$? ?B|?:?Za?hB????t?9?????5;?? ?8?b}n ????3HR^???K?k????^?????i^????8?Dd&???b?S?lS?fVC##?|???=?s?pm?A?h?H???????,?3A)>?m???O+[???d?d????????P?uj ??*1"??=????)?????????gDz@?}??}?7^/nySyC?9??sB)1?\u???(Q?!$???????{??I???@G?=?????R2?8?I???u*hQO?V???J??0?~?????????jx1???k???d?gJ???O???=?~?:X??&Q????wD/?f@??????????????x??ag?~g??pfz?? ??j?n?+ ??pZ??X(??????+ `?U???z???}??g?m/?????+??bzc?? ?cN???%|??N????iB?V ??,8??^?b?????2f?? ??????M?o??|Lk ???1S? gY ???3??w_???????z?v??K?g?q???J??s?|1?" ?(?????????????{??M?'???S?hr_???6W*u??[,?????`??f?R+,???.?-R5sG????I?.}?@??????=??>?d?*?UT)Y??? `?j???v???O?I??D?9?"???U ?=?F;Zw??_???q????????b?.??/Wa???9D??P?????PD?$-???H??? ?y*n? >Y!????{7?X;??z???;OeA ??A????%B??R???OF???u??-??????`?=??(??J,????????,??K?.#??1]/????????%[??[?f??;?`??^?{[?Sq?"?????uz?M?? 5& ? ?#L&*T ?#p?^??Ah9+F??:9???8?H?.&aJf??Y g??K?yr?.jo v?I`???.?G??:????xo?>?&????C?e??U?BsT??>??0mT?$v8????0-???? 7????????9???????v??G??&rEx?P?X?Xj??? }?2^?? (?/???? q?a??'?h&??????(??y?G?>????K??? ????] ??Trj ? J@?0~??B???t?"??!??L??+????????] ?71yA?????P>?? ????q????/????13?????????-v?/??&/??1 _X\DZ???V???????, k??j??7??f??????.????????ePL??????DV>I?J????A???p?|&???$??e?N????? ??|??+*?A??[? ?i?]?jE Z???y?s\?????N?i?7??Z?dDzd:?;&??F?c????? ?????l?WmU?^?D?iuRAWJ??5X????\A????{??"?UE???q?zW?,2n?A0???!????????7?AdNG???d?vk?>???v?????Uc;?"??P?? ????]??#qv?^??????yM??$"p[.?.?? i??^? ??;e?o0{??vX?m%????????1??(?g^??,U?Il#TIw?!N?m???^h *???? ?5=??????????*???[cY??C????????}??_+?yJS?8????{??f?-5?G6?x???;?B????w2?Z6P?????j??"dA'????v:N?z\??\?]?ub?????;???? ??[]qu~c,q?%q1|C?????????8????y^S&?K??Pp?????Ve?ba:q??@????B *D+??I?(?h?3?0?????? vy?????k+)@,Z?b???g???D????S! Y;!F8?=?????UT????H?2?!w?E?XLi?UE?????@L(??x?p??2,?????D/E  = ?i?e??s??$?L?)S{???????????B????10r1g,??G-p?????+?*l??%?2?j? ??Q?_ ??C?1 ?%???*i4?`x??n?N???????4?????C^?R:?si???=????e?%8?DW????? A\??B)?????v%???6?[ 8??=????fP?N??}?e?Fd???? ???Y!?Eg)a{|~?q??????????'?????nC?c}?V??|/5??????=?z?{?]~?F??U?k???L??L???M$???-Db?x?????B6 _?q??f ??k????`u???m???6f?????B?? 8-???u????}u? ? =???=_?????^'i??{?????n?q?w?-?N5o$cRN???????c?G?E ?)?}??,;%X7???? 4$i?M3??`?&??]:????z. 3???I???????Y??B?????]B)eg:??}r?~R?\?\"??\?{A???f%???? ??X\?? ??jF???T????|?????kS????;???x-u???t&??)"?+3J?????j?7jO#?<.?7????u????|???i??z?c?????>(?3?\?>??ys)??"8?+sW? ??. ?G???*?? ?a?? m????????R$??xH=????Uq??E????'E??D0:,Sfd??1- D???(?0??????D?IP???????O@?F&*??z??LN??????y?{??oN??.??av?+ ?L+??S? ??7;??3?C%3{??X8\3J?~n??u?????n.???/L)??????????[AG???FV?$????. SL@ ?_????a@?e?r zh?D?}W?~?N??? ???/??R ???P???+M ?uh&U??yoS83???{?U?<2L?? ?VC?? ??;?????=!?"1Ry??Um ?l](6?$??P????+??\Cp??lA4msw?5?K?3????*???p~??!8??????oE??"v%??? 9?o`?o??$>?-?%???3/_??1????{??8[!?? ?c??l????(V?>uyw??Q???6?6{^??F;????_V?????V?`????rL???W~?Q??O?+uR?wA????y? ,?g7V"??c?Y?,?????:^?QX????????^?V??D????? ?m|nae5?o?cO?B.?39a?yy7?4^M?0?*?.+MW?C??????0p?sL &y}U????.????M;}? nl?Ihl????1?.?????n??`T?e'???????u?E?w?"r#?n|U_'Nf]Y?t????3~ ?X??uW? K at v?? \,?L?1kZ?_???????~????,[DK?&fwno.aa???z}hb\????d ?63t!??Z?f??{u?????1,??1^????/?v6?? W?Y???(m?*??&? ??Vn5|?u? ?Q??v?$q?5?*?"A?(I,n? ??!??Hv[ ?V4T ?|^4????j??0>?,>???W????49r[???K`?=??`?KJ??@?G?i?5??[,?,?>?????h?R???I>N??9!?????????c ????l?????R?l?lE?? ?4?@??0p?E??f?iI w-z????=? ???A?sMRuU??]???A??yD?????b?dN"J77 ??l?k?8V???5??J?p-(Q??0??F?w??7!i}?g?4T??????;?6l?f??e?ZH1B??v???mU?*!??<4]???H?8&?F???'8??A??Ol]??????d????o"t???1?n???M?\? \m?=?A<G???=8L?ZB?G??0%???D ??#7?y???x?a? ????^(?(?v_ d[D+Q?g?#x2#?\?:???o??????c?=O*j????;????# u?|????l???? ?+4^?B????T|?7q?{^??!??????????????t>V???z'??O??.m?X???b?uy?x??8S???k?}I??f????'`??@N???? ?|??%?<{39?h?Q:?}??q?z???,M??4)L;??s?^?*N??????v`??? (?????S???I??/???M??oG???K???VRq)??=???u??o??eK?[2????B"_?\?%???!oU?????#9?????? 5Q?sh?E]????f???m??!!#??e ??b???E?P?e?l+???(!?"???b7_???]??fkz??3{=?=??Lc ?`f??.???S??&?c???^?F?/???>?U?o?l(???HH?9?i4??6???yNw????o?E???? g[{???????????MBx.?1?'?~?q?u^??????E" ??Q^?:? l?????o][?^}??^G[5+? ??03;????v?x_????x]??x??>???*< ????????+???? ???/O??????3?M??1??1f?J?N?J? ?????3??p??????????u4?pN?wS{?t,???=9?????E?p??x?y?n?????????o???}???????CX???4il??V@v???J???&6f???p??@?????f???srefU? o?9&jq???????#????~9??????4????c???a??!????????A$??H?n??2????bo?$\?:#V?k?n?=?XF%??1;0e(?O?c=???????? #????Yqo?((?"??????gu~??:io???}??S?}??`??/ ?Nh ?? ?>'9#ccY&T??zn!D0 Ud?ZU* "L????I???K???????????|n?!???]?}?w?J??f??w???K??????~?(j&|%Qt?????#\??d:??TPM?k#???&????????z???????[?????B?M??g?K ~?)??~????????a"?????j=TP????+???m? Os}C????????S?>??? ??????ev??9b-q?????y*??? ?)?0:zj??k?m] m[???????6y?]$^??>? ?????S??i??L|?????{+??~s>2}? ????? tuZ~????????a??? ??????f?G??P 0?)I?????)&2IM??% )?"??I#)@B1?$!?#????JY? ?uBA? A*J??V?q9? ???????;i?????L?\?;??????r??H?s??s??,?w;n??vv[ ?!??H?)a (L?dJe?b???.?u???U??n??v??.?????"L(?H??$ ??7d?)?f?m.?u?D?]?G7Nr? ??? ?p?????]n?GdN??????wr#???&?Hh??)0???.??]??E;?0JG]N?u??+???P?6;?d?q??p??H??n??? a-??2R#????A??]?!?????? ?L??????K?:tstL??.?n??iM?wi?h??v??U??Kv??bru????Qc?b??#2?]?2J3 ?R?D?)?? DIE?Ei????T9N?o???7?-7O???}???i???j?xiBQ??t? ??????????x????%D???????&?? }m??D??-??M?J!??*??????'??????{zqI!??s\]???D?? ?????8???n????e???F6T????0Z??????A??]??TEU??Po?w????Q?????K?j>?-?2?~???F?v?~?8?7??;??????????^k????"*?u??????X7kG??.??E????7:???XK???dI??UB?0*,??=]s???????????{??\????X?Ms6??*9???? ?o??O???p;?v???i??,?QV?v??b.?!???Y?????&?'C??P?? ??3/??[????9?c?~9y?? ?O??M???%?n?ii?}?k???pdV?y ?A?@$??4h?6+??4m??[????6?o?9?Q?}??F?I?-??m?d?4??V???cQ???-????? }????N?AX??]??5?_?*?QQZ4Z5?ZH??(????m???5X F6?h????EE?#I?E??DTE?6?E??b&PF??j1???h???&???,ck_???????d?cBd?????QX?Z1?o??????F???m???{j?????? ?d?LllTm?h?+c[llmQ????X??%[}?]????iE?? ?????d??? j?????V??? ?9 ?? ???88{+???F???F???*??m???????%?!??w?#zQ?}lH?X8? @q? ?3??d??>? ??K?????????E?Q??I'3???;gm2.2?G??Owq\4(#t???c??Ri?????????3Cc?*?????O\?yO+??`??Ld??|????n|[???{? |?????G???dD|7* ?CNJ??????? ??(?!??Y??Rc???Vu???? mOP?h4=G??? Z???H???#*F#????EF??-% 4Y?Yi?H????????DW?H?IDc(??J?>\TZR????B?U&"?rR(??_??N?(??y")???akV.?1n9;?)?1?^-r????\-?/?GT??5???! ????"*?(ffFa@?????8?1R???C????l?? ?)??k^???C?????'S???:[#L??????m?z?f??lr????????i4>??????"*?T?V?U?Ucgw?Z?O?Mc?6??EF????P??KD6*xh??5??4?'???g?u ?gL{}??Wd???Z?:???\>????U~??% ??P??)d;G,u?@??K?_ct???r??????) ???????t????(K ?`?vB?IB??q-F?????nW$)?P?t^FA??$???G ?Gl?:??ZgLK?????`0?=?o???jReCC????6?/k:?~r5["K?"??D??v5Y?s:n"N???w???@??~9o??????? ???W;d:1??7?3?}??{_?h(P?u???????g???w?O??s|?=Q=Y?J??????fO p? ??"??FBNn44k?8???P?O?0?+??Z? ???? ? ?zD???? ?9?M???!`F?????{oN'' ??44q6????Bi?? ????Fl??9?,????z?????/?C}?1??B??$??>@4o??#?2U?q#?k??/oO?1x???O;P??n???h(]Js}?3???{?KY??k#2????!?U?`????XH@??P???Y(?W?????(?r(???q?K???? \1Kj??@???-???n?W1&???o??%???!?!??CS?Z??1??????R??? FynY?Z???G??W?*??iL?? $??? 'B??0z???yEHC?0?s?D?* ????g-????T? &&E?e 4?H???(?y?Ry????U???o?? ??s6?M????8M#.:???[??kVn!?A''?????5??46 Z`D????@3"? JT???g7]??#???_???? ?{????q?1("Y|knW????n????? Y]?,+d???s?E%?w[1[?(?^0??$`?A?HA?4????Y??>n*(?e?????????lQZ2IX!?Zk?7?????I H?*?O j?m?0?4?_*$$?????l?] 8??s/ s?Y #?wC?????- tIli?? }l??`?????????69?$?]????V ???4???????? Y??.?C xB????Q??TC??Fr?2?M?p?r??(( ?R???)'t?YtK??" a? ?eJ%?t? ?+????pRmT?pN?qD??.?n?????????9?QTa^UT??? ?N????-?Z?????B??`?gu %?V D,????!G?'?3?m?(16!??}?S%" "??w?':??jW "??f?"??E????F????2?E????T,P?I]?Acp??7qLSl?J?D??@?}U_??m?B3???,??K9??????y%4%b?P:?!?  ???P?H?F??JM{Bs?z?{0??]W??H0'@ --- NEW FILE: sample2.ref --- ????; ?3 ?3 +b???r? ??0n up?recen?tly?b?y?the?functional?programming?comm?u-???? UA???ma? the?parsing?stage,???desugaring?and?pattern???? :?matc??9hing?0?transformations?are?carried?out.?oThese?pro-???? :?duce??y?NCore?,?O?a?minimal?functional?language?used?as???? :?an? -in??9termediate?form?in?the?Glasgo?w?Hask?ell?com-???? :?piler???[?PHHP93??#??],??\and?t??9ypical?of?the?in?termediate?forms???? :?of?|?v??|rarious?other?compilers,???for?example?the?Chalmers???? :?Hask??9ell-B??}Compiler???[?Aug87???'].? ?bindings,? ?and?substitutes?in?constan?t?bindings???? :?only?:used?once.??This?helps?to?clean?up?the?rather?messy???? :?output?`-of?the?desugarer.???The?former?feature?is?useful???? :?for?;?debugging?the?analyser.???Because?a?binding?for??Mmain???? :??m??9ust???b?A?e?supplied,???the?simpli er?will?ev?en?tually?remo?v?e???? :?all??bindings?not?reac??9hable?from??Mmain?.???If?the?analyser?is???? :?seen???to?malfunction,?? arbitrary?subsections?of?the?input???? :?program?can?b?A?e?discarded?simply?b??9y?c?hanging?the?b?A?o?dy???? :?of???Mmain?,??un??9til?what?remains?is?small?enough?to?mak?e???? :?debugging?Tviable.?????????P???? :??Remo??9ving?.?nested?en?vironmen?ts?mak?es?subsequen?t???? :?transformations?i?and?analyses?simpler.??9T??:?o?this?end,??the???? :?program?Vis? attened?out?b??9y?a?mo?A?di ed?Johnsson-st?yle???? :?lam??9b?A?da-lifter??[?Joh85???9],??!follo?w?ed?b?y?another?dep?A?endancy???? :?analysis?Tpass.?????????P???? :??The???program?is?no??9w?t?yp?A?ec?hec?k?ed,??using?a?standard???? :?Milner-Hindley??inferencer?deriv??9ed?from?Chapter?9?of???? :?P??9eyton??uJones'?b?A?o?ok??u[?P?ey87??H?].?l?Ev?ery?no?A?de?in?the?Core???? :?tree?;has?a?t??9yp?A?e?expression?attac?hed.?hAlthough?a?com-???? :?plete?mannotation?is?rather?exp?A?ensiv??9e,? ?it?is?essen?tial?for???? :?subsequen??9t?Tpasses.?????????P???? :??The??Nsingle?most?complicated?transformation,?8?higher-???? :?order??function?remo??9v??|ral?(also?kno?wn?as?sp?A?ecialisation???? :?or?z rsti cation)?no??9w?follo?ws.?(?The?presen?t?naiv?e?im-???? :?plemen??9tation,?|xdescrib?A?ed?g?in?Section?5,?is?slo??9w?but?cor-???? :?rect.??cMost???if?not?all?of?the?higher-orderness?of?t??9ypi-???? :?cal?Q?programs?can?b?A?e?remo??9v?ed.??>This?Q?transformation?is???? :?complicated??yb??9y?the?need?to?main?tain?t?yp?A?e?annotations???? :?correctly??:?.?????? gwW??:?e?.Vare?really?only?in?terested?in?deriv-????:?ing??Xev??|raluation?transformers?for?the? rst?order?func-????:?tions.?$?This?m}is?b?A?ecause?the?demand?propagated?across????:?a??/higher-order?function?largely?dep?A?ends?on?what?the????:?higher-order?@Eparameter?is.??kSo?exploiting?demand?prop-????:?agation?Xacross?higher-order?functions?means?run??9time????:?manipulation??of?ev??|raluation?transformers,??|a?serious????:?complication?Tfor?parallel?graph?reduction?systems.???????Building???and?main??9taining?the?framew?ork?is?a?tiresome,???time???????consuming?z?task.???One?could?also?argue?all?that?e ort?w??9as?un-???????necessarily??:?,?%_b?A?ecause?"*the?Glasgo??9w?Hask?ell?team?ha?v?e?sp?A?eci -???????cally??designed?their?compiler?as?a?basis?for?exp?A?erimen??9ts?lik?e???????this,??5and?f v??|ralian??9tly?supp?A?orted?those?bra?v?e?enough?to?tak?e???????them???up?[?PHHP93??#??].???In?retrosp?A?ect,???there?are?three?reasons???????wh??9y?TAnna?w?as?not?built?in?to?Glasgo?w?Hask?ell:??????????1.????:?A??9t???the?time?w?ork?on?Anna?b?A?egun,???in?the?summer?of????:?1991,??Glasgo??9w's??compiler?(v?ersion?0.02)?w?as?in?still?in????:?the?Tpro?A?cess?of?dev??9elopmen?t.???x???????2.????:?Un??9til?gFrecen?tly??:?,???the?analyser?w?as?relativ?ely?feeble,???so????:?the???need?to?feed?it?realistic?Hask??9ell?programs?has?only????:?recen??9tly?Tarisen.?????????3.????:?The???most?imp?A?ortan??9t?reason,???though,?is???this:???Anna?had????:?b?A?een??dev??9elop?ed?using?Mark?Jones'?marv??9ellous?in?terac-????:?tiv??9e???en?vironmen?t,???Gofer.??iMerging?Anna?in?to?the?Glas-????:?go??9w?? Hask?ell?w?orld?w?ould?ha?v?e?mean?t?compiling?with????:?a?y?Hask??9ell?compiler?and?this?w?ould?easily?ha?v?e?put?an????:?order?m?of?magnitude?on?the?edit-compile-run?cycle?time.????????As???Anna?b?A?ecomes?more?and?more?p?o??9w?erful,??wthe???incen?tiv?e?to???????build?'it?in??9to?a?real?compiler?gro?ws.??This?is?de nitely?a?long???????term?Tob? full?ev?aluation?is???? ?So???w?e?really?need?a? fth?p?A?oin?t?represen?ting?an???????ev??|raluator???whic??9h?do?A?es?nothing?at?all.??The?o?v?erall?in?terpreta-???????tion?Tis??MLift???(2?x?2)?.?? ??????A??9t?F?this?p?A?oin?t?it?is?con?v?enien?t?to?in?tro?A?duce?a?notation?for???????p?A?oin??9ts???to?b?e?used?throughout?this?pap?er.? KThe?b?ottom?p?oin??9t???????of??the?ab?A?o??9v?e??domain?is?written?as?an?underscore,?U??M_?.??The???????other???four?are?written?in?the?form??MU[x,???y]??where?the??MU????????stands?\Vfor?\go?up?the??MLift?",??Vand?the??Mx??and??My??are?the?relev??|ran??9t???????pro?A?duct??comp?onen??9ts.?5?The?o?v?erall?collection?of?ev??|raluators?is???????th??9us?ZVwritten??M{_,???U[0,0],?U[0,1],?U[1,0],?U[1,1]}?ZV?with???????the?Tfollo??9wing?ordering:???O??_ ??MU[1,1]????Zg\/?Y?\????> ?U[0,1]?%??U[1,0]????Zg\\?Y?/????_ ?U[0,0]????mM?|????mM?_????????Ho??9w? \do?A?es?this?generalise?to?arbitrary?non-recursiv?e?struc-???????tured?%t??9yp?A?es??K?W??:?ell,?(?v?ery?simply??:?.?K?A?% non-recursiv?e?structured???????t??9yp?A?e???is?mo?delled?b??9y?the?single?lifting?of?the?pro?duct?of?what-???????ev??9er?=Fits?t?yp?A?e?v??|rariables?are?b?ound?to.??GF??:?urther?details?are?ir-???????relev??|ran??9t.?3That's???b?A?ecause?w?e?observ?e?the?guiding?rule?that???????all???ob? f=???Lift? s,(D(te1)?x?...?x?D(ten))??????if???typeName?denotes?a?non-recursive?type???????? none?of?them?had???? f?M|???ACase??X(AnnExpr?a?b)?[AnnAlt?a?b]?? f|???ALam???[a]?(AnnExpr?a?b)????????type???AnnBind?a?b???? f=???(a,?AnnExpr?a?b)????????type???AnnAlt?a?b???? f=???(a,?([a],?AnnExpr?a?b))?????????The?? rst?and?second?parameters?on?an??MAnnExpr??t??9yp?A?e?are?for???????the?Giden??9ti er?and?annotation?t?yp?A?es?resp?ectiv??9ely??:?.???F?or?Gexam-???????ple,?Fif??in?section?2.1.??QF??:?or?non-function?v??|ralues,??\they?are???? :?as??~discussed?in?section?2.2.???F??:?or?function?v??|ralues,??they???? :?are?H?a?pair?whic??9h?w?e?write?as??M(Fnc???a?c)?,???where?H??MFnc???? :??reminds???that?this?is?a??NF???uNction?}?Con??Ctext?,???Ma??is?the???? :?abstract??3v??|ralue?of?the?argumen??9t?and??Mc??is?the?con?text?on???? :?the?9 result.???Henceforth,?A?v??|rariables?denoting?con??9texts?or???? :?con??9text?Tmaps?ha?v?e?'c'?as?their? rst?letter.???????????P???? :??NAbstract? @v??h?alues???(also?called?forw??9ards?v??|ralues).??[These???? :?are???the?second?kind?of?abstract?en??9tit?y???describ?A?ed?in?sec-???? :?tion??2.1.??They?are?designed?purely?to?con??9v?ey??con?texts???? :?to?=^an??9y?place?in?v?olving?a?call?to?an?unkno?wn?function,???? :?suc??9h???as?in?the?t?w?o?problematic?examples?ab?A?o?v?e.?zOThe???? :?abstract?+v??|ralues?of?non-function?ob? Y????????d??:?v??|ralue?2&of?a?function-v?alued?ob? V??:?ariables?N?denoting?abstract?v??|ralues?or?abstract????:?v??|ralue?Tmaps?ha??9v?e?T'a'?as?their? rst?letter.????????Notice?nho??9w?the?t?w?o?kinds?of?v??|ralues?are?m?utually?recursiv?e.???????The???o??9v?erall?output?of?the?abstract?in?terpreter?is?one?ab-???????stract?B}v??|ralue?p?A?er?Core?function.???Eac??9h?abstract?v?alue?con-???????tains???enough?information?to?propagate?demand?from?the???????o??9v?erall???result?to?eac??9h?of?the?argumen?ts,??uev?en?in?the?presence???????of?h?functional?parameters.??These?concepts?are?confusing,?}?so???????some?>2examples?are?in?order.???First,?i9de ne?four?selectors??MFncA?,????????MFncC?,????MFvalA??t?and??MFvalC??to?disassem??9ble??MFnc?s?and??MFval?s,???with???????the???b?A?eha??9viour?sho?wn?in?T??:?able?1.???Hop?A?efully?,???their?names?will???????serv??9e?Tas?a?reminder?of?their?meaning.?? ??????Let's? ??start?with?the?simplest?function?imaginable:????????Mid???::?Int?->?Int?.??The? ?only?remotely?in??9teresting?thing?w?e???????can???sa??9y?ab?A?out??Mid??is?that?it?simply?propagates?the?con?text?on???????its?4?result?to?the?con??9text?on?its?argumen?t.?z]So,??c)????????Let's?]?b?A?e?clear?what?this?is.???It's??Rnot??a?con??9text,?o?and?it's?also?? ??That's?b?A?ecause??Mc1??binds?to?a?con??9text???? So??M(FvalC???a1)??returns?the?map?used???????b??9y??dthe?functional?parameter?to?translate?con?text?on?itself?to???????con??9text??on?its? rst?argumen?t.??The?map?is?applied?to?the???????same??Yfunction?con??9text?as?w?as?built?in?the?preceding?para-???????graph,?;?except?3?that?references?to??M(FncC???c1)??are?replaced?b??9y????????Mc2?,?Twhic??9h?is?the?same?thing.???????Finally??:?,???the???abstract?v??|ralue?of?the?result?is?giv??9en?b?y?apply-???????ing??Jthe?abstract?v??|ralue?map?of?the?functional?parameter,????????M(FvalA???a1)?,??to??the?abstract?v??|ralue?of?the?second?parameter,????????Ma2?.???????Tw??9o?Aimpro?v?emen?ts?are?p?A?ossible.???Firstly??:?,?Lthe?abstract?v??|ralue???????of?+the?result?m??9ust?simply?b?A?e??M#?,?0~since?the?result?t?yp?A?e?is??MInt?.???????Secondly??:?,??examination?C~of?the?de nition?of??MFncA?C0?and??MFncC????????sho??9ws?u'that??M(Fnc???(FncA?c)?(FncC?c))?u'?is?equiv??|ralen?t?simply???????to?T?Mc?.?pThe?impro??9v?ed?Tv?ersion?is:??j??????Mapply???=?Fval?(\c1?->?FncC?c1)????9TB(\a1???->?Fval?(\c2?->?(FvalC?a1)?c2)????v??(\a2???->?#))????????The??mec??9hanism?for?dealing?with?functions?and?applications???????is?jLthe?hardest?part?of?the?abstract?in??9terpreter?to?understand.???????A?1?little?2/time?sp?A?en??9t?making?sense?of?this?last?example?is?a?wise???????in??9v?estmen?t.?? ??????Wh??9y?G?is?it?necessary?to?propagate?demand?in?to?functional???????parameters??pW??:?ell,?Tconsider:????????Madd1???x?=?apply?(+?x)?1????????If??5demand?isn't?propagated?in??9to??Mapply?'s?functional?parame-???????ter,?$there? Xwill?b?A?e?no?demand?on?term??M(+???x)??and?none?on??Mx?,???????giving?[the?impression?that??Madd1??is?not?strict,? ?when?really?it???????is.?? e???????3.3??G?Mo???re?L?ab?Ffout?abstract?values??m??????All?:onon-function?expressions?yield?an?abstract?v??|ralue?in?a?unit???????domain.??3Ho??9w?ev?er,??{v??|ralue??@?M#?,?used?in?the?examples?ab?A?o??9v?e,??{is???????? f=???Stop1???? f|???Up1?Y?[Context]???? f|???Stop2???? f|???Up2???? f|???UpUp2??X[Context]???? f|???Fnc?Y?AbsVal?Context????? f|???FncC???Context???? f|???FvalC??XAbsVal????? f|???CJoin??X[Context]???? f|???CMeet??X[Context]????? f|???CtxVar?,?Id???? f|???CtxLam?,?Id?Context???? f|???CtxAp??XContext?Context????? f|???SelU???Int?Context???? f|???SelUU??XInt?Context???? f|???CaseU??XContext?Context?Context???? f|???CaseUU?,?Context?Context?Context?Context????? f|???DefU???Context???? f|???DefUU??XContext????????The?S rst?six?are?for?building?literal?con??9texts.????MStop1??and????????MUp1?yO?p?A?ertain?to?p?oin??9ts?in??MLift???(D1?x?...?x?Dn)?,???with?yO?MStop1????????represen??9ting??the?b?A?ottom?p?oin??9t??M_?,?Y|and??M(Up1???[x1?...?xn])????????represen??9ting?the?p?A?oin?t??MU[x1???...?xn]?.?Similarly??:?,?T?MStop2?,??MUp2????????and?$u?M(UpUp2???[x1?...?xn])??represen??9t?the?p?A?oin?ts??M_?,?h=?MU_??and????????MUU[x1???...?xn]?&?in?the?domain??MLift2???(D1?x?...?x?Dn)?.????MFnc????????is??eused?for?building?function-v??|ralued?con??9texts,??/as?discussed?in???????section?Hj3.2.???Finally??:?,?U0?MDefU?H]?and??MDefUU??exist?to?help?the?term???????rewriting?Tsystem,?as?describ?A?ed?in?section?4.4.?? ???????MFncC?(??and?)!?MFvalC??w??9ere?also?discussed?in?section?3.2.????MCJoin??and????????MCMeet?]=?unsurprisingly?denote?the?least?upp?A?er?and?greatest???????lo??9w?er?Tb?A?ounds?of?their?resp?ectiv??9e?argumen?t?lists.????????MCtxVar?,????MCtxLam?L0?and??MCtxAp??are?exact?equiv??|ralen??9ts?to?the????????MAbsVar?,?"??MAbsLam????and??MAbsAp??discussed?in?section?3.3.??fThey???????pro??9vide???a?w?a?y?to?reference?con?text-v??|ralued?v?ariables,??and?al-???????lo??9w??8the?creation?and?application?of?con?text-v??|ralued?maps.???????? `??Pv?????My?? ?"?Pv?????Mz??K\?.?? ??? 1section?2.2.6:?*they?ma??9y?only?b?A?e?either?one?of?the?t?yp?A?e???????v??|rariables,?i ?Mv1???...?vk?,?or?XLa?direct?recursiv??9e?call?to?the?t?yp?A?e:????????M(typeName???v1?...?vk)?.?? ??????Because?? of?this?constrain??9t,???eac?h?? constructor?argumen??9t?in?a???????v??|ralid?&?de nition?can?b?A?e?classi ed?either?as?a?recursiv??9e?call??MRec?,???????or?Y?as?one?of?the?t??9yp?A?e?v??|rariables,?j??MVar???n??where??Mn??is?a?n?um?b?A?er???????denoting?Twhic??9h?v??|rariable.?pF??:?or?example,?the?de nition???O??????Mdata???AVLTree?i?a?b???? f=???ALeaf???? f|???ANode?i?(AVLTree?i?a?b)?a?b?(AVLTree?i?a?b)????????can,?Tin?principle,?b?A?e?rewritten?as????????Mdata???AVLTree?(of?3?type?variables)???? f=???ALeaf???? f|???ANode?(Var?1)?Rec?(Var?2)?(Var?3)?Rec????????W??:?e?) no??9w?de ne?t?w?o?strange?functions,?-??Margkind??and??Mupdate?,???????to???assist?in?the?discussion?b?A?elo??9w.? WNeither?are?mean?t?to???????b?A?e?? implemen??9table.??Rather,??xthey?serv?e?as?con?v?enien?t?nota-???????tional??Rdevices,??and?are?b?A?est?illustrated?b??9y?example.??jThey???????are???b?A?oth?meaningless?unless?the?particular?constructor?ap-???????plication?Tthey?are?asso?A?ciated?with?is?stated.?? ???????Margkind???tells?us?what?part?of?a?data?t??9yp?A?e?a?giv?en?construc-???????tor???argumen??9t?corresp?A?onds?to:???either?a?certain?t?yp?A?e?v??|rariable,???????or??3a?recursiv??9e?instance?of?the?t?yp?A?e.?eF??:?or?example,?b?earing?in???????mind?~the?declaration?ab?A?o??9v?e,??Pgiv?en?~the?constructor?applica-???????tion?T?M(ANode???i?l?a?b?r)?:????????Margkind???i?=?Var?1???????argkind???l?=?Rec???????argkind???a?=?Var?2???????argkind???b?=?Var?3???????argkind???r?=?Rec???????update?G ?replaces?a?particular?v??|ralue?in?a?supplied?list?with???????another???v??|ralue.??It? nds?out?whic??9h?lo?A?cation?to?up?date?b??9y???????using? w?Margkind?,?J at exp?A?ecting?an?answ??9er?of?the?form??M(Var???i)?,???????whereup?A?on?B??Mi??is?used?as?the?lo?cation.?? It?is?in??9v??|ralid?to?use????????Mupdate???in?a?w??9a?y??whic?h?w?ould?cause?the?call?to?argkind???????to??_return??MRec?.? _?Again,?F?using?the?constructor?application????????M(ANode???i?l?a?b?r)?:????????Mupdate???i?"my"?,?["the",?"cat",?"sat"]???? f=???["my",? s,"cat",?"sat"]????????update???a?"dog"? s,["the",?"cat",?"sat"]???? f=???["the",?"dog",?"sat"]????????update???b?"ran"? s,["the",?"cat",?"sat"]????Z?=???["the",?"cat",?"ran"]????????But????????Mupdate???l?x?xs???????update???r?x?xs????????are?Tb?A?oth?illegal?since??Margkind???l??=??Margkind?r??=??MRec?.???????? the?sak??9e?of?clarit?y??:?,?r?this?inconsequen?tial?detail?is?hence-???? f=???ARec?(update?ai?ai?topfv(D(tau)))??????if?,?argkind???ai?==?Var?x??????and? s,C???is?from?a?recursive?type????? f=???ANonRec?(update?ai?ai?topfv(D(tau)))??????if?,?argkind???ai?==?Var?x??????and? s,C???is?from?a?non-recursive?type????????Nullary??fconstructors?simply?acquire?the?top?abstract?v??|ralue???????of???the?relev??|ran??9t?domain?(b?A?ear?in?mind?that,??for?a?domain?not???????con??9taining???function?spaces,???this?is?the?same?as?the?b?A?ottom???????p?A?oin??9t).?pThe?T?M[]??case?for??M[Int]?,?for?example,?is:????????M[]???=?topfv(D(?[Int]?))???? f=???topfv(?Lift2?(Lift?())?)???? f=???ARec?[ANonRec?[]]????????The??3motiv??9e?in?all?this?is?to?ensure?that?the?abstract?v??|ralue?of???????a??constructor?application?is?c??9haracterised,??for?eac?h?parame-???????terising?Tt??9yp?A?e,?b?y?the?least?v??|ralue?of?that?t?yp?A?e.?? ??????As?K[an?example,??consider?an?ob? whilst???? f...???? fC???a1?...?an?->?rhs???? f...????????and?L?an?abstract?v??|ralue?asso?A?ciated?with??Msw??of??Mfsw?,?t?the?abstract???????v??|ralue?Tasso?A?ciated?with??Mai??is????????Mai? s,=???fsw????A(if?,?argkind???ai?==?Rec???????=???SelA?x?fsw????A(if?,?argkind???ai?==?Var?x????????Let?w?the?abstract?v??|ralue?of?the?switc??9h?expression?b?A?e?denoted????????Mfsw?.?pF??:?or?T?M[Int]??w??9e?ha?v?e:???????? fC1???p11?...?p1m?->?rhs1???? f...???? fCn???p1n?...?pnm?->?rhsn????????No??9w,?S?giv?en??con?text??Malpha??o?v?erall,?S?what?is?the?con?text?on????????Msw???`aThe??? rst?step?is?to? nd?the?con??9text?on??Mp11???...?pnm?.???????These?Tcon??9text?are?giv?en?b?y:????????M(C???p11?[rhs1]?rho1?alpha)?,?...???????(C???p1m?[rhs1]?rho1?alpha)????????...????????(C???p1n?[rhsn]?rhon?alpha)?,?...???????(C???pnm?[rhsn]?rhon?alpha)???????? f[]?Y?->???0???? f(x:xs)? s,->???x????????Clearly??:?,??k?Mvs???::?[Int]????and?the?o??9v?erall???t?yp?A?e?is??MInt?.?OSo?a?con-???????text?? ?Malpha??placed?on?the?result?m??9ust?b?A?e?in?domain??MLift???()?,???????with?Dthe?resulting?con??9text?on??Mvs??in??MLift2???(Lift?())?.???Sec-???????tion???3.5.4?indicates?that?the??M[]??case?con??9tributes?con?text????????MUpUp2???[Up1?[]]?.??No??9w,??Npropagating????Malpha??to?the??M(:)??alter-???????nativ??9e???puts?con?text??Malpha??on??Mx??and??MStop2??(that?is,??'none)?on????????Mxs?.???Com??9bining??"these?t?w?o,???again?using?section?3.5.4,?sho??9ws???????that?Tthe?con??9text?propagated?b?y?this?alternativ?e?is:????Z??MCJoin???[Up2,?CMeet?[alpha,?Stop2]]???????=???CJoin?[Up2,?Stop2]???????=???Up2????????This?Tgiv??9es?o?v?erall?con?text?on??Mvs??as:????Z??MCaseU???alpha?Stop2????> ?(CMeet???[UpUp2?[Up1?[]],?Up2])????????=???CaseU?alpha?Stop2?Up2????????That's??in??9tuitiv?ely?correct:??with?no?demand?on?the?resulting????????MInt?,?R?there's?F?no?(?MStop2?)?demand?on?the?incoming?list.???Oth-???????erwise,??w??9e??&ma?y?ev??|raluate?the?list?to?WHNF???(?MUp2?),??that?is,???????to??dthe? rst?constructor.?uIt?is?a?pit??9y?these?domains?can't?tell???????us?w?ab?A?out?the?head-strictness?here:??Ggiv??9en?non-zero?demand,???????it's?~?ob??9vious?w?e?can?not?only?ev??|raluate?to?the? rst?construc-???????tor,? f=???bot?(domain-of-x)????????The?Tv??|rariable?case?is:????????MC???x?(tau,?AVar?v)?rho?alpha???? f=???if??Xx?==?v??????then? s,alpha??????else? s,bot???(domain-of-x)????????As??b?A?efore,?9the?application?and?lam??9b?da?cases?are?a?bit?mind???????b?A?ending.????????MC???x?(tau,?ALam?[y]?e)?rho?alpha???? f=???C?x?e?rho2?(FncC?alpha)??????where????!?Trho2???=?rho?{y?->?FncA?alpha}???????? P?T??:?o?deal?with?the?former,??con-???? fc1???==?c2????????These?6yexamples?illustrate?the?problem?of?whether?to?simplify???????terms?~starting?from?the?lea??9v?es?~(innermost- rst)?or?from?the???????ro?A?ot?M?(outermost- rst).???Since,???in?the?second?example,?the???????rule?F?only?applies?if?subterms??Mc1??and??Mc2??are?pro??9v??|rably?equal,???????innermost- rst??9rewriting?seems?necessary??:?.? /But?the?same???????strategy?J?applied?to??MFvalC???(Fval?c?a))?J??could?w??9aste?a?lot???????? b?A?efore?and?after?application,??but?this?seems?ab?om-???? r}???r???Z f=???schedule(t_inner_simp)??????where????!?Tt_inner_simp????/?=???t?with?simp?applied?to?t's?subterms????????schedule(t)???? f=???rewrite_with(rulesfor(t),?t)????????rewrite_with([],???t)???? f=???t????????rewrite_with((rule:rules),???t)???? f=???case?(rule?t)?of????!?TNothing???->?rewrite_with(rules,t)????!?TJust???t2?->?schedule(t2)????????Firstly??:?,?6$?Mt?'s??asubterms?are?simpli ed,?giving??Mt_inner_simp.????????This?"?is?passed?to?in??9termediary??Mschedule?,?f[whic?h?examines???????the???ro?A?ot?sym??9b?ol?to?determine?the?relev??|ran??9t?list?of?rewrite???????rules.? )O?Mschedule??I?passes?the?rules?and?its?argumen??9t?to????????Mrewrite_with?,???whic??9h?z?w?orks?its?w?a?y?through?the?list?of?rules.???????If?2?it?runs?out?of?rules,?` it?simply?returns?the?term.???But?if?there???????is???a?rule,???it?is?applied?to?the?term.? 4This?either?has?no?e ect,???????in??whic??9h?case?the?next?rule?is?tried,?/?or?it?pro?A?duces?a?new???????term?'e?Mt2?.?R?No??9w??Mt2??ma?y?w?ell?ha?v?e?a?di eren?t?ro?A?ot?sym?b?A?ol,???????whic??9h???w?ould?in?v??|ralidate?all?the?remaining?rules.???So?rewriting???????of?T?Mt2??is?con??9tin?ued?Tb?y?passing?it?bac?k?to??Mschedule?.?? ??????The?mnet?e ect?of??Mschedule(t)??is?th??9us?to?k?eep?applying???????rewrite???rules?to?the?ro?A?ot?of??Mt??un??9til?no?applicable?rules?can???????b?A?e?5?found.? }ZThis?pro?cess?deals?prop?erly?with?c??9hanges?in???????the??ro?A?ot?sym??9b?ol.???Observ?e??that?the?call?to??Mschedule??from????????Mrewrite_with?HS?is?not?necessary?for?correctness.??mW??:?e?could???????simply?+?return??Mt2??at?this?p?A?oin??9t.???What?this?w?ould?mean?is?that???????an??9y?8?p?A?ossible?rewrites?of??Mt2??w?ould?b?A?e?dela?y?ed?un?til?the?next???????simpli cation?7?pass,?drather?than?b?A?eing?done?straigh??9t?a?w?a?y??:?.???So???????omitting?~?the?re-sc??9hedule?implies?more?simpli cation?passes???????and?Ta?serious?loss?of?eciency??:?.??5???????4.3??G?Dealing?L?with?lamb?Ffdas?and?applications??m??????The???presence?of??MAbsLam?,?^??MAbsAp??and??MAbsVar??terms?in??9tro-???????duces???the?need?to?p?A?erform?lam??9b?da?calculus-lik??9e?substi-???????tution.? ?*What???follo??9ws?applies?equally?to?the?dual?con-???????structions????MCtxLam?,???MCtxAp??and??MCtxVar?.??sIn?particular,????????Msimp?|U?needs?to?b?A?e?able?to?deal?with?terms?of?the?form????????M(AbsAp???(AbsLam?v?e)?a)?.? pNaturally??:?,???w??9e???can?reac?h?di-???????rectly?B?for?the?blunderbuss?solution:? w?devise?a?function????????Msubst(e,v,a)?X??to?replace?free?o?A?ccurrences?of??Mv??in??Me??with??Ma,????????and?Templo??9y?it?in?the?rewrite?rule:????????MAbsAp???(AbsLam?v?e)?a?,?===>?subst(e,v,a)????????Tw??9o?Adefects?are?apparen?t.???Firstly??:?,?L?since??Msimp??is?committed???????to?8?doing?innermost- rst?simpli cation,?d?b?A?oth?function?and?ar-???????gumen??9t?B?are?simpli ed?extensiv?ely?b?A?efore?substitution?b?egins.???????Our???hands?are?no??9w?tied:???w?e?cannot?mak?e?the?lam?b?A?da/apply???????term??ereduction?an??9y?lazier.???Ineciency?is?the?second?com-???????plain??9t.?0?This?q]sc?heme?demands?a?complete?substitution?pass???????o??9v?er?T?Me??for?ev??9ery?argumen?t.???????? f===>?,?UpUp2???[?CMeet?[SelUU?1?e,?y1],????P?0CMeet???[SelUU?2?e,?y2]?]???O??????All??in?all,???a?rather?elegan??9t?solution?to?a?tric?ky?problem.???????There?Tis?just?one? nal?ca??9v?eat.?pConsider:????????Msimp???selenv?(CaseU?e?a?b)????????If??Fw??9e?cannot? nd?a?v??|ralue?for??Me??in??Mselenv?,???the??MCaseU????expres-???????sion???ma??9y?still?b?A?e?remo?v??|rable?b?y?the?follo?wing?means.?E:Find???????in???Mselenv??a?k??9ey??Mk??for?whic?h?w?e?can?pro?v?e?that???Mk???Pv??zg?Me?? 3??,???????and??(for?whic??9h??Mk??is?b?A?ound?to?some??MUp1???[...]??v??|ralue.???So??Me????????m??9ust?&also?bind?to?some??MUp1???[...]??v??|ralue,?*Cso?w?e?can?replace????????M(CaseU???e?a?b)???b??9y??M(CaseU???(DefU?e)?a?b)?.?'?MCaseUU?s??are,??as???????ev??9er,?W?analogous.???So?Jgw?e?migh?t?b?A?e?able?to?do?just?a?little?bit???????b?A?etter? ?m??9y?taking?monotonicit?y?of?k?eys?in?to?accoun?t?when???????searc??9hing?T?Mselenv?.??5???????4.5??G?Avoiding?L?an?exp?Ffonential?explosion??m??????Although?4?w??9e?ha?v?e?a?v?oided?non-termination?via?in nite???????branc??9hing,???another???insidious?problem?lurks:?.terms?whic?h???????expand??,exp?A?onen??9tially?for?a?while,??"b?efore?shrinking?bac??9k?to???????a?#compact?normal?form.??Suc??9h?b?A?eha?viour?causes?the?term???????rewriter??lto?run?out?of?memory?simplifying?seemingly?in-???????signi can??9t??expressions.?yThe?problem?manifests?itself,???once???????again,?n?with?\??MCaseU?\??and??MCaseUU??terms.???The?normal?form?re-???????quires???that?the?switc??9h?expression?cannot?itself?b?A?e?a??MCaseU????or????????MCaseUU?,?Tgiving?rise?to?some?rules?of?the?form:????????MCaseUU???(CaseUU?a?b?c?d)?e?f?g???????===>???????CaseUU???a?(CaseUU?b?e?f?g)????&m?(CaseUU???c?e?f?g)????&m?(CaseUU???d?e?f?g)????????The??zproblem?o?A?ccurs?b?ecause?of?the?w??9a?y??z?Mrewrite_with??at-???????tempts??5to?apply?rewrite?rules?to?the?ro?A?ot?term?un??9til?no?more???????can??b?A?e?found.???If??Ma??is?itself?a??MCaseUU???term,?Dh?Mrewrite_with????????will???immediately?reapply?the?rule,??Mtrebling?the?expres-???????sion???size?again.? 1rIt?w??9ould?b?A?e?b?etter?to?lo?ok?to?see?if???????w??9e???can?do?some?simpli cations?on?the??M(CaseUU???b?e?f?g)?,????????M(CaseUU???c?e?f?g)?k??and??M(CaseUU???d?e?f?g)?k??terms??Rb??efor?e?k??se-???????lecting?F?another?rewrite?rule?for?the?ro?A?ot?term.???There's?a???????v??9ery?yZgo?A?o?d?c??9hance?w?e?can,???b?A?ecause?it?is?lik?ely?that?w?e?already???????kno??9w???enough?ab?A?out??Mb?,???Mc??and??Md??to?eliminate?their?asso?ciated????????MCaseUU?s.?i?It?/"ma??9y?also?turn?out?that??Ma??is?the?same?as??Mb?,?5??Mc??or????????Md?,?Tand?this?is?helpful?to?A?o.?? ??????Implemen??9ting?o?this?is?not?only?easy??:?,??jbut?essen?tial.?+?When????????Mrewrite_with?I$?detects?that?a?rewrite?rule?has?created?a????????MCaseUU?3??term,???it?4do?A?es?not?immediately?seek?out?another???????rewrite??arule?for?the?ro?A?ot?term.?}?Instead,?$it?tries?to?rewrite???????the???subterms?as?m??9uc?h???as?p?A?ossible,???and?only?then?lo?oks?again???????at?3?b?->?b)?->?b?->?[a]?->?b????????Giv??9en?[)Lthe?usual???????Hask??9ell?!?de nition?of??M(++)???::?[c]?->?[c]?->?[c]?,?d?w??9e?can???????de ne???????? nThe?second?pass???? ?Mmain??ma??9y?b?A?e?of?an?y?t?yp?A?e,??6w?e?trivially?monomor-???? f?Minstances?Y?"toVisit?? ?? 15.861?TM?33? 43.239?TM?33? {so?neither?has?an?unfair?adv??|ran-???? ?systems,? ?and?to?Barney?Hilk??9en?for?an?in?v??|raluable?insigh?t???????regarding??separate?compilation?systems.?? Mark?Jones?pro-???????vided??man??9y?in?teresting?commen?ts?ab?A?out?monomorphisation???????and?Oz rsti cation,?^and?outlined?the?instance-collecting?algo-???????rithm???of?Section?5.6.1.? ?Geo rey?Burn?and?Denis?Ho??9w?e???w?ere???????sucien??9tly?8?bra?v?e?to?exp?A?erimen?t?with?the?implemen?tation,???????and?Tpro??9vided?useful?feedbac?k.?? ??????Denis???Ho??9w?e?read?an?early?draft?in?min?ute?detail.? :His?exten-???????siv??9e??|and?sometimes?am?using????-=?2????#?commen?ts?pro?v?ed?v?ery?helpful???????in?Tmaking?the?presen??9tation?clearer.????????References???????????[Aug87]???fL.?|Augustsson.???RCompiling?J?L??azy?F??J?unctional?L?an-????fguages,?l?Part?f?II?.?h?PhD?/?thesis,?6WChalmers?/?T??:?eknisk??|ra????fH??`ogsk??9ola,?TG?oteb?A?org,?Sw??9eden,?1987.???????????[Aug93]???fLennart???Augustsson.?b?Implemen??9ting?hask?ell?o?v?er-????floading.?-?In???RPr??o?c?e?e?dings?AEof?the?F??J?unctional?Pr??o-????fgr??amming??`L?anguages?and?Computer?A???r?chite?ctur?e????fConfer??enc?e,?N 2GB) in a reasonable amount of time. I suggest you use the undocumented --exponential option to bzip2 when compressing the resulting file; this saves a bit of time. Note: *don't* bother with --exponential when compressing Real Files; it'll just waste a lot of CPU time :-) (but is otherwise harmless). */ #define _FILE_OFFSET_BITS 64 #include #include /* The number of megabytes of junk to spew out (roughly) */ #define MEGABYTES 5000 #define N_BUF 1000000 char buf[N_BUF]; int main ( int argc, char** argv ) { int ii, kk, p; srandom(1); setbuffer ( stdout, buf, N_BUF ); for (kk = 0; kk < MEGABYTES * 515; kk+=3) { p = 25+random()%50; for (ii = 0; ii < p; ii++) printf ( "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ); for (ii = 0; ii < p-1; ii++) printf ( "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" ); for (ii = 0; ii < p+1; ii++) printf ( "ccccccccccccccccccccccccccccccccccccc" ); } fflush(stdout); return 0; } --- NEW FILE: unzcrash.c --- /* A test program written to test robustness to decompression of corrupted data. Usage is unzcrash filename and the program will read the specified file, compress it (in memory), and then repeatedly decompress it, each time with a different bit of the compressed data inverted, so as to test all possible one-bit errors. This should not cause any invalid memory accesses. If it does, I want to know about it! p.s. As you can see from the above description, the process is incredibly slow. A file of size eg 5KB will cause it to run for many hours. */ #include #include #include "bzlib.h" #define M_BLOCK 1000000 typedef unsigned char uchar; #define M_BLOCK_OUT (M_BLOCK + 1000000) uchar inbuf[M_BLOCK]; uchar outbuf[M_BLOCK_OUT]; uchar zbuf[M_BLOCK + 600 + (M_BLOCK / 100)]; int nIn, nOut, nZ; static char *bzerrorstrings[] = { "OK" ,"SEQUENCE_ERROR" ,"PARAM_ERROR" ,"MEM_ERROR" ,"DATA_ERROR" ,"DATA_ERROR_MAGIC" ,"IO_ERROR" ,"UNEXPECTED_EOF" ,"OUTBUFF_FULL" ,"???" /* for future */ ,"???" /* for future */ ,"???" /* for future */ ,"???" /* for future */ ,"???" /* for future */ ,"???" /* for future */ }; void flip_bit ( int bit ) { int byteno = bit / 8; int bitno = bit % 8; uchar mask = 1 << bitno; //fprintf ( stderr, "(byte %d bit %d mask %d)", // byteno, bitno, (int)mask ); zbuf[byteno] ^= mask; } int main ( int argc, char** argv ) { FILE* f; int r; int bit; int i; if (argc != 2) { fprintf ( stderr, "usage: unzcrash filename\n" ); return 1; } f = fopen ( argv[1], "r" ); if (!f) { fprintf ( stderr, "unzcrash: can't open %s\n", argv[1] ); return 1; } nIn = fread ( inbuf, 1, M_BLOCK, f ); fprintf ( stderr, "%d bytes read\n", nIn ); nZ = M_BLOCK; r = BZ2_bzBuffToBuffCompress ( zbuf, &nZ, inbuf, nIn, 9, 0, 30 ); assert (r == BZ_OK); fprintf ( stderr, "%d after compression\n", nZ ); for (bit = 0; bit < nZ*8; bit++) { fprintf ( stderr, "bit %d ", bit ); flip_bit ( bit ); nOut = M_BLOCK_OUT; r = BZ2_bzBuffToBuffDecompress ( outbuf, &nOut, zbuf, nZ, 0, 0 ); fprintf ( stderr, " %d %s ", r, bzerrorstrings[-r] ); if (r != BZ_OK) { fprintf ( stderr, "\n" ); } else { if (nOut != nIn) { fprintf(stderr, "nIn/nOut mismatch %d %d\n", nIn, nOut ); return 1; } else { for (i = 0; i < nOut; i++) if (inbuf[i] != outbuf[i]) { fprintf(stderr, "mismatch at %d\n", i ); return 1; } if (i == nOut) fprintf(stderr, "really ok!\n" ); } } flip_bit ( bit ); } #if 0 assert (nOut == nIn); for (i = 0; i < nOut; i++) { if (inbuf[i] != outbuf[i]) { fprintf ( stderr, "difference at %d !\n", i ); return 1; } } #endif fprintf ( stderr, "all ok\n" ); return 0; } --- NEW FILE: words0 --- If compilation produces errors, or a large number of warnings, please read README.COMPILATION.PROBLEMS -- you might be able to adjust the flags in this Makefile to improve matters. --- NEW FILE: words1 --- Doing 6 tests (3 compress, 3 uncompress) ... If there's a problem, things might stop at this point. --- NEW FILE: words2 --- Checking test results. If any of the four "cmp"s which follow report any differences, something is wrong. If you can't easily figure out what, please let me know (jseward at acm.org). --- NEW FILE: words3 --- If you got this far and the "cmp"s didn't complain, it looks like you're in business. To install in /usr/bin, /usr/lib, /usr/man and /usr/include, type make install To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type make install PREFIX=/xxx/yyy If you are (justifiably) paranoid and want to see what 'make install' is going to do, you can first do make -n install or make -n install PREFIX=/xxx/yyy respectively. The -n instructs make to show the commands it would execute, but not actually execute them. Instructions for use are in the preformatted manual page, in the file bzip2.txt. For more detailed documentation, read the full manual. It is available in Postscript form (manual.ps), PDF form (manual.pdf), and HTML form (manual_toc.html). You can also do "bzip2 --help" to see some helpful information. "bzip2 -L" displays the software license. _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sun Jun 6 15:15:46 2004 From: tismer at centera.de (Christian Tismer) Date: Sun, 06 Jun 2004 15:15:46 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core stacklesseval.c, 1.158, 1.159 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv26678/Stackless/core Modified Files: stacklesseval.c Log Message: temporary debug checkin Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.158 retrieving revision 1.159 diff -C2 -d -r1.158 -r1.159 *** a/stacklesseval.c 6 Jun 2004 12:53:06 -0000 1.158 --- b/stacklesseval.c 6 Jun 2004 13:15:44 -0000 1.159 *************** *** 93,96 **** --- 93,97 ---- /* reuse it */ (*cst)->task = task; + printf("cstack new probable error, true=%d %d\n", ts->st.nesting_level, (*cst)->nesting_level); return *cst; } _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:03:44 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:03:44 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/PCbuild _sre.dsp, 1.6, 1.7 python.dsp, 1.7, 1.8 pythoncore.dsp, 1.60, 1.61 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/PCbuild In directory centera.de:/tmp/cvs-serv3004/PCbuild Modified Files: _sre.dsp python.dsp pythoncore.dsp Log Message: Stackless 3.1 almost ready. All tests are working, both Python and Stackless, both soft and hard switching. New features: channels are working cross-thread! Stack protection for eval_frame and pickling is complete. A couple of smallish features are missing: pickling of channels refuse running tasklets from foreign threads channel.transfer scheduling strategy cross-thread cframe pickling, get rid of invalid_exec funcs, instead use the missing cframe owner-tasklet pointer! add more tests! Index: _sre.dsp =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/PCbuild/_sre.dsp,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** _sre.dsp 29 Apr 2004 02:18:40 -0000 1.6 --- _sre.dsp 2 Jun 2004 23:03:42 -0000 1.7 *************** *** 114,118 **** # ADD BASE LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1e0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_sre.pyd" # SUBTRACT BASE LINK32 /pdb:none ! # ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1e0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_sre.pyd" # SUBTRACT LINK32 /pdb:none --- 114,118 ---- # ADD BASE LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1e0000" /subsystem:windows /dll /debug /machine:I386 /out:"./_sre.pyd" # SUBTRACT BASE LINK32 /pdb:none ! # ADD LINK32 user32.lib kernel32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /base:"0x1e1e0000" /subsystem:windows /dll /debug /machine:I386 /out:"./off/_sre.pyd" # SUBTRACT LINK32 /pdb:none Index: python.dsp =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/PCbuild/python.dsp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** python.dsp 29 Apr 2004 02:18:40 -0000 1.7 --- python.dsp 2 Jun 2004 23:03:42 -0000 1.8 *************** *** 104,108 **** # ADD BASE LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 # SUBTRACT BASE LINK32 /pdb:none ! # ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 # SUBTRACT LINK32 /pdb:none --- 104,108 ---- # ADD BASE LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 # SUBTRACT BASE LINK32 /pdb:none ! # ADD LINK32 odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib /nologo /base:"0x1d000000" /subsystem:console /debug /machine:I386 /out:"./off/python.exe" # SUBTRACT LINK32 /pdb:none Index: pythoncore.dsp =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/PCbuild/pythoncore.dsp,v retrieving revision 1.60 retrieving revision 1.61 diff -C2 -d -r1.60 -r1.61 *** pythoncore.dsp 29 Apr 2004 21:02:34 -0000 1.60 --- pythoncore.dsp 2 Jun 2004 23:03:42 -0000 1.61 *************** *** 185,188 **** --- 185,192 ---- # Begin Source File + SOURCE=..\Stackless\core\stackless_methods.h + # End Source File + # Begin Source File + SOURCE=..\Stackless\core\stackless_structs.h # End Source File *************** *** 371,374 **** --- 375,382 ---- # Begin Source File + SOURCE=..\Include\descrobject.h + # End Source File + # Begin Source File + SOURCE=..\Objects\dictobject.c # End Source File _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sun Jun 6 17:04:43 2004 From: tismer at centera.de (Christian Tismer) Date: Sun, 06 Jun 2004 17:04:43 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core cframeobject.c, 1.70, 1.71 stackless_impl.h, 1.95, 1.96 stacklesseval.c, 1.161, 1.162 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv29520/Stackless/core Modified Files: cframeobject.c stackless_impl.h stacklesseval.c Log Message: re-activated cstack caching, makes very much sense, partially 30 percent more speed. Also added caches for cframes and bombs. Index: cframeobject.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/cframeobject.c,v retrieving revision 1.70 retrieving revision 1.71 diff -C2 -d -r1.70 -r1.71 *** a/cframeobject.c 24 May 2004 01:01:20 -0000 1.70 --- b/cframeobject.c 6 Jun 2004 15:04:41 -0000 1.71 *************** *** 31,34 **** --- 31,37 ---- #include "pickling/prickelpit.h" + static PyCFrameObject *free_list = NULL; + static int numfree = 0; /* number of cframes currently in free_list */ + #define MAXFREELIST 200 /* max value for numfree */ static void *************** *** 40,44 **** Py_XDECREF(cf->ob2); Py_XDECREF(cf->ob3); ! PyObject_GC_Del(cf); } --- 43,53 ---- Py_XDECREF(cf->ob2); Py_XDECREF(cf->ob3); ! if (numfree < MAXFREELIST) { ! ++numfree; ! cf->f_back = (PyFrameObject *) free_list; ! free_list = cf; ! } ! else ! PyObject_GC_Del(cf); } *************** *** 84,90 **** PyFrameObject *back; ! cf = PyObject_GC_NewVar(PyCFrameObject, &PyCFrame_Type, 0); ! if (cf == NULL) ! return NULL; back = ts->frame; --- 93,108 ---- PyFrameObject *back; ! if (free_list == NULL) { ! cf = PyObject_GC_NewVar(PyCFrameObject, &PyCFrame_Type, 0); ! if (cf == NULL) ! return NULL; ! } ! else { ! assert(numfree > 0); ! --numfree; ! cf = free_list; ! free_list = (PyCFrameObject *) free_list->f_back; ! _Py_NewReference((PyObject *) cf); ! } back = ts->frame; *************** *** 305,307 **** --- 323,340 ---- run_cframe, REF_INVALID_EXEC(run_cframe)); } + + /* Clear out the free list */ + + void + slp_cstack_fini(void) + { + while (free_list != NULL) { + PyCFrameObject *cf = free_list; + free_list = (PyCFrameObject *) free_list->f_back; + PyObject_GC_Del(cf); + --numfree; + } + assert(numfree == 0); + } + #endif Index: stackless_impl.h =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stackless_impl.h,v retrieving revision 1.95 retrieving revision 1.96 diff -C2 -d -r1.95 -r1.96 *** a/stackless_impl.h 3 Jun 2004 18:02:11 -0000 1.95 --- b/stackless_impl.h 6 Jun 2004 15:04:41 -0000 1.96 *************** *** 59,63 **** /* clean-up up at the end */ ! PyAPI_FUNC(void) PyStacklessEval_Fini(void); PyAPI_FUNC(void) PyStackless_kill_tasks_with_stacks(int allthreads); --- 59,67 ---- /* clean-up up at the end */ ! PyAPI_FUNC(void) slp_stacklesseval_fini(void); ! PyAPI_FUNC(void) slp_scheduling_fini(void); ! PyAPI_FUNC(void) slp_cstack_fini(void); ! ! PyAPI_FUNC(void) PyStackless_Fini(void); PyAPI_FUNC(void) PyStackless_kill_tasks_with_stacks(int allthreads); Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.161 retrieving revision 1.162 diff -C2 -d -r1.161 -r1.162 *** a/stacklesseval.c 6 Jun 2004 14:05:05 -0000 1.161 --- b/stacklesseval.c 6 Jun 2004 15:04:41 -0000 1.162 *************** *** 43,46 **** --- 43,65 ---- ******************************************************/ + static PyCStackObject *cstack_cache[CSTACK_SLOTS] = { NULL }; + static int cstack_cachecount = 0; + + /* this function will get called by PyStacklessEval_Fini */ + static void slp_cstack_cacheclear(void) + { + int i; + PyCStackObject *stack; + + for (i=0; i < CSTACK_SLOTS; i++) { + while (cstack_cache[i] != NULL) { + stack = cstack_cache[i]; + cstack_cache[i] = (PyCStackObject *) stack->startaddr; + PyObject_Del(stack); + } + } + cstack_cachecount = 0; + } + static void cstack_dealloc(PyCStackObject *cst) *************** *** 49,53 **** SLP_CHAIN_REMOVE(PyCStackObject, &slp_cstack_chain, cst, next, prev); ! PyObject_Del(cst); } --- 68,81 ---- SLP_CHAIN_REMOVE(PyCStackObject, &slp_cstack_chain, cst, next, prev); ! if (cst->ob_size >= CSTACK_SLOTS) { ! PyObject_Del(cst); ! } ! else { ! if (cstack_cachecount >= CSTACK_MAXCACHE) ! slp_cstack_cacheclear(); ! cst->startaddr = (int *) cstack_cache[cst->ob_size]; ! cstack_cache[cst->ob_size] = cst; ! ++cstack_cachecount; ! } } *************** *** 67,71 **** Py_DECREF(*cst); } ! *cst = PyObject_NewVar(PyCStackObject, &PyCStack_Type, size); if (*cst == NULL) return NULL; --- 95,106 ---- Py_DECREF(*cst); } ! if (size < CSTACK_SLOTS && ((*cst) = cstack_cache[size])) { ! /* take stack from cache */ ! cstack_cache[size] = (PyCStackObject *) (*cst)->startaddr; ! --cstack_cachecount; ! _Py_NewReference((PyObject *)(*cst)); ! } ! else ! *cst = PyObject_NewVar(PyCStackObject, &PyCStack_Type, size); if (*cst == NULL) return NULL; *************** *** 295,304 **** } - void - PyStacklessEval_Fini(void) - { - /* no caching at the moment */ - } - /* cstack spilling for recursive calls */ --- 330,333 ---- *************** *** 581,584 **** --- 610,620 ---- } + /* Clear out the free list */ + + void + slp_stacklesseval_fini(void) + { + slp_cstack_cacheclear(); + } #endif /* STACKLESS */ _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:03:45 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:03:45 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Objects abstract.c, 1.13, 1.14 classobject.c, 1.18, 1.19 descrobject.c, 1.15, 1.16 funcobject.c, 1.11, 1.12 methodobject.c, 1.10, 1.11 typeobject.c, 1.15, 1.16 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Objects In directory centera.de:/tmp/cvs-serv3004/Objects Modified Files: abstract.c classobject.c descrobject.c funcobject.c methodobject.c typeobject.c Log Message: Stackless 3.1 almost ready. All tests are working, both Python and Stackless, both soft and hard switching. New features: channels are working cross-thread! Stack protection for eval_frame and pickling is complete. A couple of smallish features are missing: pickling of channels refuse running tasklets from foreign threads channel.transfer scheduling strategy cross-thread cframe pickling, get rid of invalid_exec funcs, instead use the missing cframe owner-tasklet pointer! add more tests! Index: abstract.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/abstract.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** abstract.c 29 Apr 2004 17:58:58 -0000 1.13 --- abstract.c 2 Jun 2004 23:03:42 -0000 1.14 *************** *** 2202,2206 **** /* we use the same flag here, since iterators are not callable */ #endif ! STACKLESS_PROMOTE(iter); result = (*iter->ob_type->tp_iternext)(iter); STACKLESS_ASSERT(); --- 2202,2206 ---- /* we use the same flag here, since iterators are not callable */ #endif ! STACKLESS_PROMOTE_METHOD(iter, tp_iternext); result = (*iter->ob_type->tp_iternext)(iter); STACKLESS_ASSERT(); Index: classobject.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/classobject.c,v retrieving revision 1.18 retrieving revision 1.19 diff -C2 -d -r1.18 -r1.19 *** classobject.c 24 May 2004 23:45:14 -0000 1.18 --- classobject.c 2 Jun 2004 23:03:42 -0000 1.19 *************** *** 2071,2080 **** (setattrofunc)instance_setattr, /* tp_setattro */ 0, /* tp_as_buffer */ - #ifdef STACKLESS - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES | - Py_TPFLAGS_HAVE_STACKLESS_CALL, /*tp_flags*/ - #else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_CHECKTYPES,/*tp_flags*/ - #endif instance_doc, /* tp_doc */ (traverseproc)instance_traverse, /* tp_traverse */ --- 2071,2075 ---- *************** *** 2097,2100 **** --- 2092,2096 ---- }; + STACKLESS_DECLARE_METHOD(&PyInstance_Type, tp_call) /* Instance method objects are used for two purposes: *************** *** 2496,2505 **** PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ - #ifdef STACKLESS - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */ - #else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - #endif instancemethod_doc, /* tp_doc */ (traverseproc)instancemethod_traverse, /* tp_traverse */ --- 2492,2496 ---- *************** *** 2522,2525 **** --- 2513,2518 ---- }; + STACKLESS_DECLARE_METHOD(&PyMethod_Type, tp_call) + /* Clear out the free list */ Index: descrobject.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/descrobject.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** descrobject.c 24 May 2004 01:59:34 -0000 1.15 --- descrobject.c 2 Jun 2004 23:03:42 -0000 1.16 *************** *** 398,402 **** --- 398,406 ---- } + #ifdef STACKLESS + PyTypeObject PyMethodDescr_Type = { + #else static PyTypeObject PyMethodDescr_Type = { + #endif PyObject_HEAD_INIT(&PyType_Type) 0, *************** *** 419,428 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ - #ifdef STACKLESS - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */ - #else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - #endif 0, /* tp_doc */ descr_traverse, /* tp_traverse */ --- 423,427 ---- *************** *** 441,446 **** --- 440,451 ---- }; + STACKLESS_DECLARE_METHOD(&PyMethodDescr_Type, tp_call) + /* This is for METH_CLASS in C, not for "f = classmethod(f)" in Python! */ + #ifdef STACKLESS + PyTypeObject PyClassMethodDescr_Type = { + #else static PyTypeObject PyClassMethodDescr_Type = { + #endif PyObject_HEAD_INIT(&PyType_Type) 0, *************** *** 463,472 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ - #ifdef STACKLESS - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */ - #else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - #endif 0, /* tp_doc */ descr_traverse, /* tp_traverse */ --- 468,472 ---- *************** *** 485,488 **** --- 485,490 ---- }; + STACKLESS_DECLARE_METHOD(&PyClassMethodDescr_Type, tp_call) + static PyTypeObject PyMemberDescr_Type = { PyObject_HEAD_INIT(&PyType_Type) *************** *** 582,591 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ - #ifdef STACKLESS - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */ - #else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - #endif 0, /* tp_doc */ descr_traverse, /* tp_traverse */ --- 584,588 ---- *************** *** 604,607 **** --- 601,606 ---- }; + STACKLESS_DECLARE_METHOD(&PyWrapperDescr_Type, tp_call) + static PyDescrObject * descr_new(PyTypeObject *descrtype, PyTypeObject *type, char *name) *************** *** 680,683 **** --- 679,685 ---- descr->d_base = base; descr->d_wrapped = wrapped; + #ifdef STACKLESS + descr->d_slpmask = 0; + #endif } return (PyObject *)descr; *************** *** 968,997 **** }; - #ifdef STACKLESS - #define WRAP_RETURN(call) { \ - PyObject * retval; \ - STACKLESS_PROMOTE_FLAG( \ - wp->descr->d_base->flags & PyWrapperFlag_STACKLESS && \ - wp->descr->d_type->tp_flags & Py_TPFLAGS_HAVE_STACKLESS_CALL); \ - retval = (call); \ - STACKLESS_ASSERT(); \ - return retval; \ - } - #else - #define WRAP_RETURN(call) return (call); - #endif - static PyObject * wrapper_call(wrapperobject *wp, PyObject *args, PyObject *kwds) { - #ifdef STACKLESS STACKLESS_GETARG(); - #endif wrapperfunc wrapper = wp->descr->d_base->wrapper; PyObject *self = wp->self; if (wp->descr->d_base->flags & PyWrapperFlag_KEYWORDS) { wrapperfunc_kwds wk = (wrapperfunc_kwds)wrapper; ! WRAP_RETURN( (*wk)(self, args, wp->descr->d_wrapped, kwds) ) } --- 970,987 ---- }; static PyObject * wrapper_call(wrapperobject *wp, PyObject *args, PyObject *kwds) { STACKLESS_GETARG(); wrapperfunc wrapper = wp->descr->d_base->wrapper; PyObject *self = wp->self; + PyObject *ret; if (wp->descr->d_base->flags & PyWrapperFlag_KEYWORDS) { wrapperfunc_kwds wk = (wrapperfunc_kwds)wrapper; ! STACKLESS_PROMOTE_WRAPPER(wp); ! ret = (*wk)(self, args, wp->descr->d_wrapped, kwds); ! STACKLESS_ASSERT(); ! return ret; } *************** *** 1002,1006 **** return NULL; } ! WRAP_RETURN( (*wrapper)(self, args, wp->descr->d_wrapped) ) } --- 992,999 ---- return NULL; } ! STACKLESS_PROMOTE_WRAPPER(wp); ! ret = (*wrapper)(self, args, wp->descr->d_wrapped); ! STACKLESS_ASSERT(); ! return ret; } *************** *** 1051,1060 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ - #ifdef STACKLESS - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */ - #else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC, /* tp_flags */ - #endif 0, /* tp_doc */ wrapper_traverse, /* tp_traverse */ --- 1044,1048 ---- *************** *** 1073,1076 **** --- 1061,1066 ---- }; + STACKLESS_DECLARE_METHOD(&PyMethodWrapper_Type, tp_call) + PyObject * PyWrapper_New(PyObject *d, PyObject *self) Index: funcobject.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/funcobject.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** funcobject.c 29 Apr 2004 17:58:58 -0000 1.11 --- funcobject.c 2 Jun 2004 23:03:42 -0000 1.12 *************** *** 549,558 **** PyObject_GenericSetAttr, /* tp_setattro */ 0, /* tp_as_buffer */ - #ifdef STACKLESS - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_HAVE_STACKLESS_CALL,/* tp_flags */ - #else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - #endif func_doc, /* tp_doc */ (traverseproc)func_traverse, /* tp_traverse */ --- 549,553 ---- *************** *** 575,578 **** --- 570,574 ---- }; + STACKLESS_DECLARE_METHOD(&PyFunction_Type, tp_call) /* Class method object */ Index: methodobject.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/methodobject.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** methodobject.c 2 May 2004 15:07:06 -0000 1.10 --- methodobject.c 2 Jun 2004 23:03:42 -0000 1.11 *************** *** 281,290 **** 0, /* tp_setattro */ 0, /* tp_as_buffer */ - #ifdef STACKLESS - Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | - Py_TPFLAGS_HAVE_STACKLESS_CALL, /* tp_flags */ - #else Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,/* tp_flags */ - #endif 0, /* tp_doc */ (traverseproc)meth_traverse, /* tp_traverse */ --- 281,285 ---- *************** *** 301,304 **** --- 296,301 ---- }; + STACKLESS_DECLARE_METHOD(&PyCFunction_Type, tp_call) + /* List all methods in a chain -- helper for findmethodinchain */ Index: typeobject.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Objects/typeobject.c,v retrieving revision 1.15 retrieving revision 1.16 diff -C2 -d -r1.15 -r1.16 *** typeobject.c 24 May 2004 23:45:14 -0000 1.15 --- typeobject.c 2 Jun 2004 23:03:42 -0000 1.16 *************** *** 2977,2980 **** --- 2977,2998 ---- (basebase == NULL || base->SLOT != basebase->SLOT)) + #ifdef STACKLESS + + #define COPYSLOT2(SLOT, SLPSLOT) \ + if (!type->SLOT && SLOTDEFINED(SLOT)) { \ + type->SLOT = base->SLOT; \ + if (type->tp_flags & base->tp_flags & \ + Py_TPFLAGS_HAVE_STACKLESS_EXTENSION) \ + type->slpflags.SLPSLOT = base->slpflags.SLPSLOT; \ + } + + #define COPYSLOT(SLOT) COPYSLOT2(SLOT, SLOT) + + #define COPYNUM(SLOT) COPYSLOT2(tp_as_number->SLOT, SLOT) + #define COPYSEQ(SLOT) COPYSLOT2(tp_as_sequence->SLOT, SLOT) + #define COPYMAP(SLOT) COPYSLOT2(tp_as_mapping->SLOT, SLOT) + #define COPYBUF(SLOT) COPYSLOT2(tp_as_buffer->SLOT, SLOT) + + #else #define COPYSLOT(SLOT) \ if (!type->SLOT && SLOTDEFINED(SLOT)) type->SLOT = base->SLOT *************** *** 2985,2988 **** --- 3003,3008 ---- #define COPYBUF(SLOT) COPYSLOT(tp_as_buffer->SLOT) + #endif + /* This won't inherit indirect slots (from tp_as_number etc.) if type doesn't provide the space. */ *************** *** 3148,3151 **** --- 3168,3181 ---- type->tp_flags |= Py_TPFLAGS_READYING; + #ifdef STACKLESS + /* extract/spread the stackless call flag */ + if (type->tp_flags & Py_TPFLAGS_HAVE_STACKLESS_EXTENSION) { + if (type->slpflags.tp_call) + type->tp_flags |= Py_TPFLAGS_HAVE_STACKLESS_CALL; + else if (type->tp_flags & Py_TPFLAGS_HAVE_STACKLESS_CALL) + type->slpflags.tp_call = -1; + } + #endif + #ifdef Py_TRACE_REFS /* PyType_Ready is the closest thing we have to a choke point *************** *** 4427,4430 **** --- 4457,4461 ---- slot_tp_repr(PyObject *self) { + STACKLESS_GETARG(); PyObject *func, *res; static PyObject *repr_str; *************** *** 4432,4436 **** --- 4463,4469 ---- func = lookup_method(self, "__repr__", &repr_str); if (func != NULL) { + STACKLESS_PROMOTE_ALL(); res = PyEval_CallObject(func, NULL); + STACKLESS_ASSERT(); Py_DECREF(func); return res; *************** *** 4444,4447 **** --- 4477,4481 ---- slot_tp_str(PyObject *self) { + STACKLESS_GETARG(); PyObject *func, *res; static PyObject *str_str; *************** *** 4449,4453 **** --- 4483,4489 ---- func = lookup_method(self, "__str__", &str_str); if (func != NULL) { + STACKLESS_PROMOTE_ALL(); res = PyEval_CallObject(func, NULL); + STACKLESS_ASSERT(); Py_DECREF(func); return res; *************** *** 4455,4459 **** else { PyErr_Clear(); ! return slot_tp_repr(self); } } --- 4491,4498 ---- else { PyErr_Clear(); ! STACKLESS_PROMOTE_ALL(); ! res = slot_tp_repr(self); ! STACKLESS_ASSERT(); ! return res; } } *************** *** 4462,4465 **** --- 4501,4505 ---- slot_tp_hash(PyObject *self) { + STACKLESS_GETARG(); /* not supported */ PyObject *func; static PyObject *hash_str, *eq_str, *cmp_str; *************** *** 4527,4533 **** slot_tp_getattro(PyObject *self, PyObject *name) { static PyObject *getattribute_str = NULL; ! return call_method(self, "__getattribute__", &getattribute_str, "(O)", name); } --- 4567,4579 ---- slot_tp_getattro(PyObject *self, PyObject *name) { + STACKLESS_GETARG(); static PyObject *getattribute_str = NULL; ! PyObject *ret; ! ! STACKLESS_PROMOTE_ALL(); ! ret = call_method(self, "__getattribute__", &getattribute_str, "(O)", name); + STACKLESS_ASSERT(); + return ret; } *************** *** 4535,4538 **** --- 4581,4585 ---- slot_tp_getattr_hook(PyObject *self, PyObject *name) { + STACKLESS_GETARG(); /* partially supported */ PyTypeObject *tp = self->ob_type; PyObject *getattr, *getattribute, *res; *************** *** 4552,4559 **** } getattr = _PyType_Lookup(tp, getattr_str); if (getattr == NULL) { /* No __getattr__ hook: use a simpler dispatcher */ tp->tp_getattro = slot_tp_getattro; ! return slot_tp_getattro(self, name); } getattribute = _PyType_Lookup(tp, getattribute_str); --- 4599,4609 ---- } getattr = _PyType_Lookup(tp, getattr_str); + STACKLESS_PROMOTE_ALL(); if (getattr == NULL) { /* No __getattr__ hook: use a simpler dispatcher */ tp->tp_getattro = slot_tp_getattro; ! res = slot_tp_getattro(self, name); ! STACKLESS_ASSERT(); ! return res; } getattribute = _PyType_Lookup(tp, getattribute_str); *************** *** 4567,4572 **** --- 4617,4624 ---- if (res == NULL && PyErr_ExceptionMatches(PyExc_AttributeError)) { PyErr_Clear(); + STACKLESS_PROMOTE_ALL(); res = PyObject_CallFunction(getattr, "OO", self, name); } + STACKLESS_ASSERT(); return res; } *************** *** 4575,4578 **** --- 4627,4631 ---- slot_tp_setattro(PyObject *self, PyObject *name, PyObject *value) { + STACKLESS_GETARG(); /* not supported */ PyObject *res; static PyObject *delattr_str, *setattr_str; *************** *** 4603,4606 **** --- 4656,4660 ---- half_richcompare(PyObject *self, PyObject *other, int op) { + STACKLESS_GETARG(); PyObject *func, *args, *res; static PyObject *op_str[6]; *************** *** 4616,4620 **** --- 4670,4676 ---- res = NULL; else { + STACKLESS_PROMOTE_ALL(); res = PyObject_Call(func, args, NULL); + STACKLESS_ASSERT(); Py_DECREF(args); } *************** *** 4629,4636 **** --- 4685,4695 ---- slot_tp_richcompare(PyObject *self, PyObject *other, int op) { + STACKLESS_GETARG(); PyObject *res; if (self->ob_type->tp_richcompare == slot_tp_richcompare) { + STACKLESS_PROMOTE_ALL(); res = half_richcompare(self, other, op); + STACKLESS_ASSERT(); if (res != Py_NotImplemented) return res; *************** *** 4638,4642 **** --- 4697,4703 ---- } if (other->ob_type->tp_richcompare == slot_tp_richcompare) { + STACKLESS_PROMOTE_ALL(); res = half_richcompare(other, self, swapped_op[op]); + STACKLESS_ASSERT(); if (res != Py_NotImplemented) { return res; *************** *** 4651,4654 **** --- 4712,4716 ---- slot_tp_iter(PyObject *self) { + STACKLESS_GETARG(); PyObject *func, *res; static PyObject *iter_str, *getitem_str; *************** *** 4659,4663 **** --- 4721,4727 ---- args = res = PyTuple_New(0); if (args != NULL) { + STACKLESS_PROMOTE_ALL(); res = PyObject_Call(func, args, NULL); + STACKLESS_ASSERT(); Py_DECREF(args); } *************** *** 4679,4684 **** slot_tp_iternext(PyObject *self) { static PyObject *next_str; ! return call_method(self, "next", &next_str, "()"); } --- 4743,4754 ---- slot_tp_iternext(PyObject *self) { + STACKLESS_GETARG(); static PyObject *next_str; ! PyObject *ret; ! ! STACKLESS_PROMOTE_ALL(); ! ret = call_method(self, "next", &next_str, "()"); ! STACKLESS_ASSERT(); ! return ret; } *************** *** 4686,4692 **** --- 4756,4764 ---- slot_tp_descr_get(PyObject *self, PyObject *obj, PyObject *type) { + STACKLESS_GETARG(); PyTypeObject *tp = self->ob_type; PyObject *get; static PyObject *get_str = NULL; + PyObject *ret; if (get_str == NULL) { *************** *** 4707,4711 **** if (type == NULL) type = Py_None; ! return PyObject_CallFunction(get, "OOO", self, obj, type); } --- 4779,4786 ---- if (type == NULL) type = Py_None; ! STACKLESS_PROMOTE_ALL(); ! ret = PyObject_CallFunction(get, "OOO", self, obj, type); ! STACKLESS_ASSERT(); ! return ret; } *************** *** 4713,4716 **** --- 4788,4792 ---- slot_tp_descr_set(PyObject *self, PyObject *target, PyObject *value) { + STACKLESS_GETARG(); /* not supported */ PyObject *res; static PyObject *del_str, *set_str; *************** *** 4731,4734 **** --- 4807,4811 ---- slot_tp_init(PyObject *self, PyObject *args, PyObject *kwds) { + STACKLESS_GETARG(); /* not yet supported */ static PyObject *init_str; PyObject *meth = lookup_method(self, "__init__", &init_str); *************** *** 4748,4751 **** --- 4825,4829 ---- slot_tp_new(PyTypeObject *type, PyObject *args, PyObject *kwds) { + STACKLESS_GETARG(); static PyObject *new_str; PyObject *func; *************** *** 4773,4777 **** --- 4851,4857 ---- PyTuple_SET_ITEM(newargs, i+1, x); } + STACKLESS_PROMOTE_ALL(); x = PyObject_Call(func, newargs, kwds); + STACKLESS_ASSERT(); Py_DECREF(newargs); Py_DECREF(func); *************** *** 4782,4785 **** --- 4862,4866 ---- slot_tp_del(PyObject *self) { + STACKLESS_GETARG(); /* not supported */ static PyObject *del_str = NULL; PyObject *del, *res; *************** *** 4862,4865 **** --- 4943,4981 ---- #undef RBINSLOT + #ifdef STACKLESS + + #define HEAPOFF(x) offsetof(PyHeapTypeObject, slpflags.x) + + #define TPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ + {NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ + PyDoc_STR(DOC), HEAPOFF(SLOT)} + #define FLSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC, FLAGS) \ + {NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ + PyDoc_STR(DOC), HEAPOFF(SLOT), FLAGS} + #define ETSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC, SLPSLOT) \ + {NAME, offsetof(PyHeapTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ + PyDoc_STR(DOC), HEAPOFF(SLPSLOT)} + + #define SQSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ + ETSLOT(NAME, as_sequence.SLOT, FUNCTION, WRAPPER, DOC, SLOT) + #define MPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ + ETSLOT(NAME, as_mapping.SLOT, FUNCTION, WRAPPER, DOC, SLOT) + #define NBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ + ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, DOC, SLOT) + #define UNSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ + ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, \ + "x." NAME "() <==> " DOC, SLOT) + #define IBSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ + ETSLOT(NAME, as_number.SLOT, FUNCTION, WRAPPER, \ + "x." NAME "(y) <==> x" DOC "y", SLOT) + #define BINSLOT(NAME, SLOT, FUNCTION, DOC) \ + ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_l, \ + "x." NAME "(y) <==> x" DOC "y", SLOT) + #define RBINSLOT(NAME, SLOT, FUNCTION, DOC) \ + ETSLOT(NAME, as_number.SLOT, FUNCTION, wrap_binaryfunc_r, \ + "x." NAME "(y) <==> y" DOC "x", SLOT) + + #else + #define TPSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ {NAME, offsetof(PyTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ *************** *** 4871,4874 **** --- 4987,4991 ---- {NAME, offsetof(PyHeapTypeObject, SLOT), (void *)(FUNCTION), WRAPPER, \ PyDoc_STR(DOC)} + #define SQSLOT(NAME, SLOT, FUNCTION, WRAPPER, DOC) \ ETSLOT(NAME, as_sequence.SLOT, FUNCTION, WRAPPER, DOC) *************** *** 4890,4893 **** --- 5007,5012 ---- "x." NAME "(y) <==> y" DOC "x") + #endif + static slotdef slotdefs[] = { SQSLOT("__len__", sq_length, slot_sq_length, wrap_inquiry, *************** *** 5035,5046 **** TPSLOT("__hash__", tp_hash, slot_tp_hash, wrap_hashfunc, "x.__hash__() <==> hash(x)"), - #ifdef STACKLESS - FLSLOT("__call__", tp_call, slot_tp_call, (wrapperfunc)wrap_call, - "x.__call__(...) <==> x(...)", - PyWrapperFlag_KEYWORDS | PyWrapperFlag_STACKLESS), - #else FLSLOT("__call__", tp_call, slot_tp_call, (wrapperfunc)wrap_call, "x.__call__(...) <==> x(...)", PyWrapperFlag_KEYWORDS), - #endif TPSLOT("__getattribute__", tp_getattro, slot_tp_getattr_hook, wrap_binaryfunc, "x.__getattribute__('name') <==> x.name"), --- 5154,5159 ---- *************** *** 5068,5079 **** TPSLOT("__iter__", tp_iter, slot_tp_iter, wrap_unaryfunc, "x.__iter__() <==> iter(x)"), - #ifdef STACKLESS - FLSLOT("next", tp_iternext, slot_tp_iternext, wrap_next, - "x.next() -> the next value, or raise StopIteration", - PyWrapperFlag_STACKLESS), - #else TPSLOT("next", tp_iternext, slot_tp_iternext, wrap_next, "x.next() -> the next value, or raise StopIteration"), - #endif TPSLOT("__get__", tp_descr_get, slot_tp_descr_get, wrap_descr_get, "descr.__get__(obj[, type]) -> value"), --- 5181,5186 ---- *************** *** 5438,5441 **** --- 5545,5555 ---- if (descr == NULL) return -1; + #ifdef STACKLESS + if (type->tp_flags & Py_TPFLAGS_HAVE_STACKLESS_EXTENSION) { + PyWrapperDescrObject * d = + (PyWrapperDescrObject *) descr; + d->d_slpmask = ((signed char *) type)[p->slp_offset]; + } + #endif if (PyDict_SetItem(dict, p->name_strobj, descr) < 0) return -1; _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:06:02 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:06:02 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Lib/test test_hotshot.py, 1.2, 1.3 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Lib/test In directory centera.de:/tmp/cvs-serv3416/Lib/test Modified Files: test_hotshot.py Log Message: had some debug crap left Index: test_hotshot.py =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Lib/test/test_hotshot.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** test_hotshot.py 2 Jun 2004 23:03:43 -0000 1.2 --- test_hotshot.py 2 Jun 2004 23:05:59 -0000 1.3 *************** *** 30,34 **** def next(self, index=None): try: - 1 << 42##!! return hotshot.log.LogReader.next(self) except StopIteration: --- 30,33 ---- _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Tue Jun 29 17:54:40 2004 From: tismer at centera.de (Christian Tismer) Date: Tue, 29 Jun 2004 17:54:40 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/PCbuild bz2.dsp, 1.2, 1.3 pcbuild.dsw, 1.14, 1.15 zlib.dsp, 1.4, 1.5 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/PCbuild In directory centera.de:/tmp/cvs-serv1274/PCbuild Modified Files: bz2.dsp pcbuild.dsw zlib.dsp Log Message: added Ghostscript (just for a while, I think this should be simplified) Index: bz2.dsp =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/PCbuild/bz2.dsp,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** a/bz2.dsp 14 Jan 2004 19:11:08 -0000 1.2 --- b/bz2.dsp 29 Jun 2004 15:54:37 -0000 1.3 *************** *** 55,59 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 ! # ADD LINK32 ..\..\bzip2-1.0.2\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./bz2.pyd" # SUBTRACT LINK32 /pdb:none /nodefaultlib --- 55,59 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 ! # ADD LINK32 ..\..\bzip2-1.0.2\Release\libbz2.lib /nologo /base:"0x1D170000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./bz2.pyd" # SUBTRACT LINK32 /pdb:none /nodefaultlib Index: pcbuild.dsw =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/PCbuild/pcbuild.dsw,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** a/pcbuild.dsw 11 Mar 2004 15:26:04 -0000 1.14 --- b/pcbuild.dsw 29 Jun 2004 15:54:37 -0000 1.15 *************** *** 217,220 **** --- 217,232 ---- ############################################################################### + Project: "pyghostscript"="..\..\..\..\..\projects\PharmaControl\pyghostscript-0.1\pyghostscript.dsp" - Package Owner=<4> + + Package=<5> + {{{ + }}} + + Package=<4> + {{{ + }}} + + ############################################################################### + Project: "python"=.\python.dsp - Package Owner=<4> Index: zlib.dsp =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/PCbuild/zlib.dsp,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** a/zlib.dsp 14 Jan 2004 19:11:08 -0000 1.4 --- b/zlib.dsp 29 Jun 2004 15:54:37 -0000 1.5 *************** *** 45,49 **** F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.4" /I "..\Stackless" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 --- 45,49 ---- F90=df.exe # ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MD /W3 /GX /Zi /O2 /I "..\Include" /I "..\PC" /I "..\..\zlib-1.2.1" /I "..\Stackless" /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "NDEBUG" /mktyplib203 /o "NUL" /win32 *************** *** 55,64 **** LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 ! # ADD LINK32 ..\..\zlib-1.1.4\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib.pyd" # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" PreLink_Desc=Checking static zlib has been built ! PreLink_Cmds=cd ..\..\zlib-1.1.4 nmake -nologo -f msdos\makefile.w32 zlib.lib # End Special Build Tool --- 55,64 ---- LINK32=link.exe # ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /dll /machine:I386 ! # ADD LINK32 ..\..\zlib-1.2.1\zlib.lib /nologo /base:"0x1e1B0000" /subsystem:windows /dll /debug /machine:I386 /nodefaultlib:"libc" /out:"./zlib.pyd" # SUBTRACT LINK32 /pdb:none # Begin Special Build Tool SOURCE="$(InputPath)" PreLink_Desc=Checking static zlib has been built ! PreLink_Cmds=cd ..\..\zlib-1.2.1 nmake -nologo -f win32/Makefile.msc zlib.lib # End Special Build Tool *************** *** 78,82 **** F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\zlib-1.1.4" /I "..\Stackless" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 --- 78,82 ---- F90=df.exe # ADD BASE CPP /nologo /MTd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /YX /FD /c ! # ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /I "..\Include" /I "..\PC" /I "..\..\zlib-1.2.1" /I "..\Stackless" /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /YX /FD /c # ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 # ADD MTL /nologo /D "_DEBUG" /mktyplib203 /o "NUL" /win32 _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sun Jun 6 15:58:16 2004 From: tismer at centera.de (Christian Tismer) Date: Sun, 06 Jun 2004 15:58:16 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/module scheduling.c, 1.105, 1.106 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/module In directory centera.de:/tmp/cvs-serv27390/Stackless/module Modified Files: scheduling.c Log Message: solved a quite hard to find bug in cstack allocation. I think it is now time to publish Stackless 3.1 :-) Index: scheduling.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/scheduling.c,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** a/scheduling.c 6 Jun 2004 12:53:04 -0000 1.105 --- b/scheduling.c 6 Jun 2004 13:58:14 -0000 1.106 *************** *** 819,827 **** ++ts->st.nesting_level; - printf("schedule ++ %d\n", ts->st.nesting_level); if ((ts->exc_type != NULL ? transfer_with_exc : slp_transfer)( cstprev, next->cstate, prev) == 0) { --ts->st.nesting_level; - printf("schedule -- %d\n", ts->st.nesting_level); retval = prev->tempval; Py_INCREF(retval); --- 819,825 ---- *************** *** 898,902 **** /* even there is a (buggy) nesting, ensure soft switch */ if (ts->st.nesting_level != 0) { ! printf("error, nesting_level = %d\n", ts->st.nesting_level); ts->st.nesting_level = 0; } --- 896,900 ---- /* even there is a (buggy) nesting, ensure soft switch */ if (ts->st.nesting_level != 0) { ! printf("XXX error, nesting_level = %d\n", ts->st.nesting_level); ts->st.nesting_level = 0; } _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:08:51 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:08:51 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless stackless_version.h, 1.43, 1.44 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless In directory centera.de:/tmp/cvs-serv3588/Stackless Modified Files: stackless_version.h Log Message: this is Stackless 3.1 beta 3 Index: stackless_version.h =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/stackless_version.h,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** stackless_version.h 25 Apr 2004 03:09:02 -0000 1.43 --- stackless_version.h 2 Jun 2004 23:08:47 -0000 1.44 *************** *** 1,7 **** /* * Stackless Python version string ! * created at Sun Apr 25 05:06:12 2004 by mkversion.py */ /* keep this entry up-to-date */ ! #define STACKLESS_VERSION "3.0 040425" --- 1,7 ---- /* * Stackless Python version string ! * created at Thu Jun 03 01:02:25 2004 by mkversion.py */ /* keep this entry up-to-date */ ! #define STACKLESS_VERSION "3.1b3 040603" _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Wed Jun 30 01:18:12 2004 From: tismer at centera.de (Christian Tismer) Date: Wed, 30 Jun 2004 01:18:12 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/bzip2-1.0.2 libbz2.def, NONE, 1.1 Message-ID: Update of /home/cvs/slpdev/src/2.3/bzip2-1.0.2 In directory centera.de:/tmp/cvs-serv12411 Added Files: libbz2.def Log Message: missing file... --- NEW FILE: libbz2.def --- LIBRARY LIBBZ2 DESCRIPTION "libbzip2: library for data compression" EXPORTS BZ2_bzCompressInit BZ2_bzCompress BZ2_bzCompressEnd BZ2_bzDecompressInit BZ2_bzDecompress BZ2_bzDecompressEnd BZ2_bzReadOpen BZ2_bzReadClose BZ2_bzReadGetUnused BZ2_bzRead BZ2_bzWriteOpen BZ2_bzWrite BZ2_bzWriteClose BZ2_bzWriteClose64 BZ2_bzBuffToBuffCompress BZ2_bzBuffToBuffDecompress BZ2_bzlibVersion BZ2_bzopen BZ2_bzdopen BZ2_bzread BZ2_bzwrite BZ2_bzflush BZ2_bzclose BZ2_bzerror _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:03:45 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:03:45 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/pickling prickelpit.c, 1.81, 1.82 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/pickling In directory centera.de:/tmp/cvs-serv3004/Stackless/pickling Modified Files: prickelpit.c Log Message: Stackless 3.1 almost ready. All tests are working, both Python and Stackless, both soft and hard switching. New features: channels are working cross-thread! Stack protection for eval_frame and pickling is complete. A couple of smallish features are missing: pickling of channels refuse running tasklets from foreign threads channel.transfer scheduling strategy cross-thread cframe pickling, get rid of invalid_exec funcs, instead use the missing cframe owner-tasklet pointer! add more tests! Index: prickelpit.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/pickling/prickelpit.c,v retrieving revision 1.81 retrieving revision 1.82 diff -C2 -d -r1.81 -r1.82 *** prickelpit.c 24 May 2004 01:01:21 -0000 1.81 --- prickelpit.c 2 Jun 2004 23:03:43 -0000 1.82 *************** *** 272,275 **** --- 272,280 ---- PyObject *message; PyThreadState *tstate = PyThreadState_GET(); + + /* if we already have an exception, we keep it */ + if (retval == NULL) + goto err_exit; + message = PyString_FromFormat("cannot execute invalid frame with " "'%.100s': frame had a C state that" *************** *** 286,289 **** --- 291,296 ---- err_exit: tstate->frame = f->f_back; + Py_DECREF(f); + --tstate->recursion_depth; Py_XDECREF(retval); return NULL; _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 01:03:46 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 01:03:46 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/module channelobject.c, 1.49, 1.50 flextype.c, 1.11, 1.12 scheduling.c, 1.99, 1.100 stacklessmodule.c, 1.173, 1.174 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/module In directory centera.de:/tmp/cvs-serv3004/Stackless/module Modified Files: channelobject.c flextype.c scheduling.c stacklessmodule.c Log Message: Stackless 3.1 almost ready. All tests are working, both Python and Stackless, both soft and hard switching. New features: channels are working cross-thread! Stack protection for eval_frame and pickling is complete. A couple of smallish features are missing: pickling of channels refuse running tasklets from foreign threads channel.transfer scheduling strategy cross-thread cframe pickling, get rid of invalid_exec funcs, instead use the missing cframe owner-tasklet pointer! add more tests! Index: channelobject.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/channelobject.c,v retrieving revision 1.49 retrieving revision 1.50 diff -C2 -d -r1.49 -r1.50 *** channelobject.c 24 May 2004 17:42:14 -0000 1.49 --- channelobject.c 2 Jun 2004 23:03:42 -0000 1.50 *************** *** 427,430 **** --- 427,431 ---- if (interthread) { /* interthread, always keep target! */ + slp_current_insert(target); } else { *************** *** 549,558 **** klass, args); STACKLESS_ASSERT(); ! if (retval == NULL) { goto err_exit; } - else if (STACKLESS_UNWINDING(retval)) { - return retval; - } Py_INCREF(Py_None); retval = Py_None; --- 550,556 ---- klass, args); STACKLESS_ASSERT(); ! if (retval == NULL || STACKLESS_UNWINDING(retval)) { goto err_exit; } Py_INCREF(Py_None); retval = Py_None; Index: flextype.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/flextype.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** flextype.c 24 May 2004 01:01:20 -0000 1.11 --- flextype.c 2 Jun 2004 23:03:42 -0000 1.12 *************** *** 137,141 **** reset_gc( (PyTypeObject *) type); #endif ! if (bindmethods(&type->type.type)) { Py_DECREF((PyObject *) type); return NULL; --- 137,141 ---- reset_gc( (PyTypeObject *) type); #endif ! if (bindmethods((PyTypeObject *) type)) { Py_DECREF((PyObject *) type); return NULL; Index: scheduling.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/scheduling.c,v retrieving revision 1.99 retrieving revision 1.100 diff -C2 -d -r1.99 -r1.100 *** scheduling.c 24 May 2004 23:36:20 -0000 1.99 --- scheduling.c 2 Jun 2004 23:03:42 -0000 1.100 *************** *** 381,385 **** ts->exc_value = cf->ob2; ts->exc_traceback = cf->ob3; ! cf->ob2 = cf->ob2 = cf->ob3 = NULL; Py_DECREF(cf); ts->frame = f; --- 381,385 ---- ts->exc_value = cf->ob2; ts->exc_traceback = cf->ob3; ! cf->ob1 = cf->ob2 = cf->ob3 = NULL; Py_DECREF(cf); ts->frame = f; Index: stacklessmodule.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/stacklessmodule.c,v retrieving revision 1.173 retrieving revision 1.174 diff -C2 -d -r1.173 -r1.174 *** stacklessmodule.c 24 May 2004 01:45:38 -0000 1.173 --- stacklessmodule.c 2 Jun 2004 23:03:42 -0000 1.174 *************** *** 12,15 **** --- 12,16 ---- #include "channelobject.h" #include "pickling/prickelpit.h" + #include "core/stackless_methods.h" /****************************************************** *************** *** 192,196 **** ts->st.ticker = ts->st.interval; current->flags.pending_irq = 1; ! /* no incref, just a flag */ return Py_None; } --- 193,197 ---- ts->st.ticker = ts->st.interval; current->flags.pending_irq = 1; ! Py_INCREF(Py_None); return Py_None; } *************** *** 198,204 **** current->flags.pending_irq = 0; - Py_INCREF(ts->st.main); - slp_current_insert(ts->st.main); - return slp_schedule_task(ts->st.current, ts->st.main, 1); } --- 199,202 ---- *************** *** 955,958 **** --- 953,966 ---- } + static int init_stackless_methods() + { + _stackless_method *p = _stackless_methtable; + + for (; p->type != NULL; p++) { + ((signed char *) p->type)[p->offset] = -1; + } + return 0; + } + /* this one must be called very early, before modules are used */ *************** *** 961,964 **** --- 969,973 ---- { if (0 + || init_stackless_methods() || init_cframetype() || init_flextype() _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Sat Jun 5 22:10:41 2004 From: tismer at centera.de (Christian Tismer) Date: Sat, 05 Jun 2004 22:10:41 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/module scheduling.c, 1.103, 1.104 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/module In directory centera.de:/tmp/cvs-serv5155/Stackless/module Modified Files: scheduling.c Log Message: added debug output. There must be an optimization problem with nesting_level Index: scheduling.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/module/scheduling.c,v retrieving revision 1.103 retrieving revision 1.104 diff -C2 -d -r1.103 -r1.104 *** a/scheduling.c 5 Jun 2004 20:02:10 -0000 1.103 --- b/scheduling.c 5 Jun 2004 20:10:38 -0000 1.104 *************** *** 895,899 **** assert(ts->st.nesting_level == 0); /* even there is a (buggy) nesting, ensure soft switch */ ! ts->st.nesting_level = 0; /* update what's not yet updated */ --- 895,902 ---- assert(ts->st.nesting_level == 0); /* even there is a (buggy) nesting, ensure soft switch */ ! if (ts->st.nesting_level != 0) { ! printf("error, nesting_level = %d\n", ts->st.nesting_level); ! ts->st.nesting_level = 0; ! } /* update what's not yet updated */ _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins From tismer at centera.de Thu Jun 3 19:07:36 2004 From: tismer at centera.de (Christian Tismer) Date: Thu, 03 Jun 2004 19:07:36 +0200 Subject: [Stackless-checkins] CVS: slpdev/src/2.3/dev/Stackless/core slp_transfer.c, 1.22, 1.23 stackless_impl.h, 1.91, 1.92 stacklesseval.c, 1.151, 1.152 Message-ID: Update of /home/cvs/slpdev/src/2.3/dev/Stackless/core In directory centera.de:/tmp/cvs-serv6819/Stackless/core Modified Files: slp_transfer.c stackless_impl.h stacklesseval.c Log Message: moved initial stub creation ibnto slp_transfer.c, to prevend inlining (gcc 3.3.2 problem) Index: slp_transfer.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/slp_transfer.c,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** slp_transfer.c 24 May 2004 01:01:20 -0000 1.22 --- slp_transfer.c 3 Jun 2004 17:07:34 -0000 1.23 *************** *** 46,49 **** --- 46,75 ---- #include "platf/slp_platformselect.h" + /* this function must be here, too, to prevend inlining */ + + int + slp_make_initial_stub(void) + { + PyThreadState *ts = PyThreadState_GET(); + + if (ts->st.initial_stub != NULL) { + Py_DECREF(ts->st.initial_stub); + ts->st.initial_stub = NULL; + } + ts->st.serial_last_jump = ++ts->st.serial; + if (slp_transfer(&ts->st.initial_stub, NULL, NULL)) return -1; + ts->st.initial_stub->serial = ts->st.serial; + /* + * from here, we always arrive with a compatible cstack + * that also can be used by main, if it is running + * in soft-switching mode. + * To insure that, it was necessary to re-create the + * initial stub for *every* run of a new main. + * This will vanish with greenlet-like stack management. + */ + + return 0; + } + static int climb_stack_and_transfer(PyCStackObject **cstprev, PyCStackObject *cst, Index: stackless_impl.h =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stackless_impl.h,v retrieving revision 1.91 retrieving revision 1.92 diff -C2 -d -r1.91 -r1.92 *** stackless_impl.h 3 Jun 2004 12:19:15 -0000 1.91 --- stackless_impl.h 3 Jun 2004 17:07:34 -0000 1.92 *************** *** 44,47 **** --- 44,49 ---- PyAPI_FUNC(void) slp_cstack_restore(PyCStackObject *cst); + PyAPI_FUNC(int) slp_make_initial_stub(void); + PyAPI_FUNC(int) slp_transfer(PyCStackObject **cstprev, PyCStackObject *cst, PyTaskletObject *prev); Index: stacklesseval.c =================================================================== RCS file: /home/cvs/slpdev/src/2.3/dev/Stackless/core/stacklesseval.c,v retrieving revision 1.151 retrieving revision 1.152 diff -C2 -d -r1.151 -r1.152 *** stacklesseval.c 2 Jun 2004 23:03:43 -0000 1.151 --- stacklesseval.c 3 Jun 2004 17:07:34 -0000 1.152 *************** *** 213,240 **** - static int - make_initial_stub(void) - { - PyThreadState *ts = PyThreadState_GET(); - - if (ts->st.initial_stub != NULL) { - Py_DECREF(ts->st.initial_stub); - ts->st.initial_stub = NULL; - } - ts->st.serial_last_jump = ++ts->st.serial; - if (slp_transfer(&ts->st.initial_stub, NULL, NULL)) return -1; - ts->st.initial_stub->serial = ts->st.serial; - /* - * from here, we always arrive with a compatible cstack - * that also can be used by main, if it is running - * in soft-switching mode. - * To insure that, it was necessary to re-create the - * initial stub for *every* run of a new main. - * This will vanish with greenlet-like stack management. - */ - - return 0; - } - static PyObject * climb_stack_and_eval_frame(PyFrameObject *f) --- 213,216 ---- *************** *** 289,293 **** ts->frame = f; ! if (make_initial_stub()) return NULL; return slp_run_tasklet(); --- 265,269 ---- ts->frame = f; ! if (slp_make_initial_stub()) return NULL; return slp_run_tasklet(); _______________________________________________ Stackless-checkins mailing list Stackless-checkins at stackless.com http://www.stackless.com/mailman/listinfo/stackless-checkins