Changeset 3d91340 in rtems-libbsd for rtemsbsd/rtems/rtems-kernel-program.c


Ignore:
Timestamp:
Jul 15, 2016, 9:39:48 AM (5 years ago)
Author:
Christian Mauderer <Christian.Mauderer@…>
Branches:
b96abfd647154f10ea8f7fac68e25676636eded5, debc0aed8b9bef9996b8ec0ae7a70b0b41912e27, 68e79b6d187fe09b0a6f3f1d22c69b4121a3f76e, freebsd-9.3, 33bfaee89aa71d2252eb48d6b9a9ec17183faced
Children:
d31a365
Parents:
fa43d6a
git-author:
Christian Mauderer <Christian.Mauderer@…> (07/15/16 09:39:48)
git-committer:
Christian Mauderer <Christian.Mauderer@…> (08/02/16 08:21:38)
Message:

rtemsbsd: Add call to program with a data restore

This adds the rtems_bsd_program_call_main_width_data_restore function.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • rtemsbsd/rtems/rtems-kernel-program.c

    rfa43d6a r3d91340  
    201201}
    202202
     203int
     204rtems_bsd_program_call_main_with_data_restore(const char *name,
     205    int (*main)(int, char **), int argc, char **argv,
     206    const void *data_buf, const size_t data_size)
     207{
     208        int exit_code = EXIT_FAILURE;
     209        void *savebuf;
     210
     211        savebuf = malloc(data_size, M_TEMP, 0);
     212        if(savebuf == NULL) {
     213                errno = ENOMEM;
     214                exit_code = EXIT_FAILURE;
     215        } else {
     216                memcpy(savebuf, data_buf, data_size);
     217                exit_code = rtems_bsd_program_call_main(name, main, argc,
     218                    argv);
     219                memcpy(data_buf, savebuf, data_size);
     220                free(savebuf, M_TEMP);
     221        }
     222
     223        return exit_code;
     224}
     225
    203226static struct mtx program_mtx;
    204227
Note: See TracChangeset for help on using the changeset viewer.