Changeset 615e83d in mainline for uspace/lib/c/generic/setjmp.c


Ignore:
Timestamp:
2018-03-08T18:25:31Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
55f068c
Parents:
e0a4686
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-08 17:43:06)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-08 18:25:31)
Message:

Turn context_save/context_restore into standard setjmp/longjmp.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/setjmp.c

    re0a4686 r615e83d  
    11/*
    22 * Copyright (c) 2013 Vojtech Horky
     3 * Copyright (c) 2018 CZ.NIC, z.s.p.o.
    34 * All rights reserved.
    45 *
     
    3031 * @{
    3132 */
    32 /** @file Long jump implementation.
    33  *
    34  * Implementation inspired by Jiri Zarevucky's code from
    35  * http://bazaar.launchpad.net/~zarevucky-jiri/helenos/stdc/revision/1544/uspace/lib/posix/setjmp.h
    36  */
    3733
    3834#include <setjmp.h>
    3935#include <context.h>
    4036
    41 // TODO: setjmp/longjmp are basically a stronger version of
    42 // context_save/context_restore. It would be preferable to turn
    43 // those two into setjmp/longjmp (all it would need is preserving the
    44 // return value).
    45 
    46 /**
    47  * Restore environment previously stored by setjmp.
    48  *
    49  * This function never returns.
    50  *
    51  * @param env Variable with the environment previously stored by call
    52  * to setjmp.
    53  * @param val Value to fake when returning from setjmp (0 is transformed to 1).
    54  */
    55 void longjmp(jmp_buf env, int val) {
    56         env[0].return_value = (val == 0) ? 1 : val;
    57         context_restore(&env[0].context);
     37/** Standard function implementation. */
     38void longjmp(jmp_buf env, int val)
     39{
     40        /* __longjmp defined in assembly doesn't "correct" the value. */
     41        __longjmp(env, val == 0 ? 1 : val);
    5842}
    5943
Note: See TracChangeset for help on using the changeset viewer.