guido carballo guerrero | 1 Jul 15:20 2009
Picon

SBCL_HOME settings

Can some body tell me how can I remove the settings of the SBCL_HOME.

Regards!

Guido

------------------------------------------------------------------------------
_______________________________________________
Sbcl-help mailing list
Sbcl-help <at> lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sbcl-help
Leslie P. Polzer | 4 Jul 11:23 2009
Picon

Re: SBCL_HOME settings


guido carballo guerrero wrote:
> Can some body tell me how can I remove the settings of the SBCL_HOME.

export SBCL_HOME=

  Leslie

--

-- 
http://www.linkedin.com/in/polzer

------------------------------------------------------------------------------
James Fleming | 4 Jul 12:39 2009
Picon

Re: SBCL_HOME settings

> guido carballo guerrero wrote:
>> Can some body tell me how can I remove the settings of the SBCL_HOME.
>
> export SBCL_HOME=
>
>   Leslie

Alternatively:
unset SBCL_HOME
(I use this whenever I rebuild SBCL on my work PC)

------------------------------------------------------------------------------
Karol Swietlicki | 5 Jul 23:17 2009
Picon

sb-ext:constant-function missing?

Hi,

The manual for SBCL lists an extension: sb-ext:constant-function.
http://www.sbcl.org/manual/Efficiency-Hacks.html

It might be just me, but I do not see it in that package and attempts
to use it fail.
Is constant-function still part of SBCL?

Karol Swietlicki

------------------------------------------------------------------------------
Nikodemus Siivola | 5 Jul 23:33 2009
Picon

Re: sb-ext:constant-function missing?

2009/7/6 Karol Swietlicki <magotari <at> gmail.com>:

> The manual for SBCL lists an extension: sb-ext:constant-function.
> http://www.sbcl.org/manual/Efficiency-Hacks.html
>
> It might be just me, but I do not see it in that package and attempts
> to use it fail. Is constant-function still part of SBCL?

Unfortunately not -- the support for it seems to have been remove as
of 0.6.9.14: no-one just noticed to update the manual.

I don't see a reason why something along the lines of
CONSTANT-FUNCTION cannot be reinstated, though.

In simple cases you can achieve a similar effect using a compiler-macro:

 (define-compiler-macro foo (&whole form &rest args)
   (if (every #'constantp args)
       (list 'quote (eval form))
       form))

Cheers,

 -- Nikodemus

------------------------------------------------------------------------------
Nikodemus Siivola | 6 Jul 00:36 2009
Picon

Re: sb-ext:constant-function missing?

2009/7/6 Nikodemus Siivola <nikodemus <at> random-state.net>:

> In simple cases you can achieve a similar effect using a compiler-macro:

Another option -- if you are not afraid to dip into internals -- is to
use DEFKNOWN:

(sb-c:defknown foo (t t) string (sb-c:foldable))

(defun foo (x y)
  (format nil "~A~A" x y))

(defun bar ()
  (let ((tmp (foo 'foo 'bar)))
    (foo tmp tmp)))

after which the disassembly of BAR looks like this:

; disassembly for BAR
; 12A5E326:       8B15F8E2A512     MOV EDX, [#x12A5E2F8]      ; "FOOBARFOOBAR"
                                                              ;
no-arg-parsing entry point
;       2C:       8BE5             MOV ESP, EBP
;       2E:       F8               CLC
;       2F:       5D               POP EBP
;       30:       C3               RET
;       31:       0F0B0A           BREAK 10                   ; error trap
;       34:       02               BYTE #X02
;       35:       18               BYTE #X18                  ;
INVALID-ARG-COUNT-ERROR
;       36:       4F               BYTE #X4F                  ; ECX

DEFKNOWN is neither supported nor documented, but used extensively inside SBCL.

Syntax is approximately:

  DEFKNOWN function-name (argument-type*) result-type (attribute*)

Two attributes of most interest are FOLDABLE which means that constant
folding is OK, and FLUSHABLE which means that the call may be
eliminated if the return value is unused.

Cheers,

 -- Nikodemus

------------------------------------------------------------------------------
Karol Swietlicki | 6 Jul 01:47 2009
Picon

Re: sb-ext:constant-function missing?

2009/7/5 Nikodemus Siivola <nikodemus <at> random-state.net>:

<snip>

Yes. That is pretty well exactly what I was hoping for. The argument
and return types will be a bit of a pickle to my preexisting macros,
but I think I can find my way around it eventually.

> Cheers,
>
>  -- Nikodemus

One day and far away, for the wishlist:
Automatic proving of a function as a pure/constant function and
setting it as foldable/flushable.

If I knew anything about compilers, I'd help a bit, but I don't. Does
not seem to be too hard to my layman eyes though.

All that we have to prove is that the substitution model holds for the
computation. This means not modifiying or using anything from outside
the function, the arguments being the only exception. If this holds
for the function and for all the functions that it calls, we should be
in the clear.

To each function add a "purity" bit. If set, the function is pure. If
all the functions being called from the function we are trying to
prove are pure, none of the input arguments are destructively modified
and no special variables are referred to, we set the purity bit. Tag
whatever we know for sure to be pure as such and let it propagate.

This would be good start, and probably not too difficult to expand later.

Of course I know not much of compilers, some of my vocabulary is
probably wrong and I'm not even that great of a programmer. So take
all I say with a grain of salt. I may be very wrong here.

Thank you very much. I think this wraps it up.
Karol Swietlicki

------------------------------------------------------------------------------
Leslie P. Polzer | 6 Jul 18:19 2009
Picon

Prevent register clobbering


I'm writing a function to interrupt a thread and take a
look at the current state of its registers.

I will use VOPs to store the register values into a known
memory location. This in itself works fine.

The problem is that a full call as in

  (interrupt-thread thread #'save-regs)

clobbers at least part of the registers (e.g. function
in EAX on x86).

I've considered using a signal handler instead of
INTERRUPT-THREAD but I'm unsure whether that will
do the job since a handler installed with
ENABLE-INTERRUPT will be run in an APPLY inside an
FLET.

Before I spent more time digging: is there a smart way
to have a direct jump to the function entry point
preventing any reg modifications?

Alternatively, can I instruct the compiler to push the
old state of the registers onto the stack?

  Leslie

--

-- 
http://www.linkedin.com/in/polzer

------------------------------------------------------------------------------
Gábor Melis | 6 Jul 18:41 2009
Picon

Re: Prevent register clobbering

On Lunes 06 Julio 2009, Leslie P. Polzer wrote:
> I'm writing a function to interrupt a thread and take a
> look at the current state of its registers.
>
> I will use VOPs to store the register values into a known
> memory location. This in itself works fine.
>
> The problem is that a full call as in
>
>   (interrupt-thread thread #'save-regs)
>
> clobbers at least part of the registers (e.g. function
> in EAX on x86).
>
> I've considered using a signal handler instead of
> INTERRUPT-THREAD but I'm unsure whether that will
> do the job since a handler installed with
> ENABLE-INTERRUPT will be run in an APPLY inside an
> FLET.
>
> Before I spent more time digging: is there a smart way
> to have a direct jump to the function entry point
> preventing any reg modifications?
>
> Alternatively, can I instruct the compiler to push the
> old state of the registers onto the stack?
>
>   Leslie

Even a C signal handler will have some registers clobbered. The 
interrupt context is already stored, see interrupt_contexts in 
src/runtime/genesis/thread.h. It's of type os_context and is platform 
specific.

Cheers, Gabor

------------------------------------------------------------------------------
Carlos Konstanski | 9 Jul 18:50 2009

"true" randomness

I have a need for better randomness.  The situation: I have an
araneida web server.  I use the following function to generate a
session id cookie:

(defun generate-sessionid ()
   "Generates a unique, random string to use as the value in a
LISPSESSIONID cookie.  The string is comprised of 16 octets in hex,
just like a PHP sessionid."
   (let ((sessionid nil))
     (dotimes (i 16)
       (let ((octet (random 256)))
         (if (< octet 16)
             (setf octet (format nil "0~x" octet))
           (setf octet (format nil "~x" octet)))
         (setf sessionid (concatenate 'string sessionid octet))))
     sessionid))

As one might expect, if I call this function x number of times, I
always get the same x session id strings because of how (random)
works.  I have never used a language that had a true random number
generator.  It is always an exercise left to the programmer.  Even my
old Timex Sinclair 1000, which seeded the random number generator from
a 16 bit counter that was incrememted every time the display was
refreshed (60 times per second), exhibited very unrandom behavior.  I
guess randomness is hard to achieve.

The problem occurs when the web server is restarted.  When that
happens, it starts generating the same session ids all over again.  If
someone has a browser open with a session id saved in it, and that
session id happens to correspond with a new user's session id, and the
new user is a superuser or admin, then the first user gets the new
user's privileges.

At the very least, I need a way to reseed (random) with some modicum
of randomness.  If even one octet can be "derailed" in my 16-octet
loop, the entire session id string would be unique.  Is there some way
to make a random-state that is suitably random?  If I call
(make-random-state t), will I get a repeatable succession of
random-state objects, or will I get something at least slightly
random?

A really great random number algorithm would be tops.  I'm thinking I
need to take the results of (random) and combine it with some other
unique data, like the current time.  Is this the right approach?

Carlos Konstanski

------------------------------------------------------------------------------
Enter the BlackBerry Developer Challenge  
This is your chance to win up to $100,000 in prizes! For a limited time, 
vendors submitting new applications to BlackBerry App World(TM) will have
the opportunity to enter the BlackBerry Developer Challenge. See full prize  
details at: http://p.sf.net/sfu/Challenge

Gmane