/* * Copyright (c) 2018 William Pitcock * * Permission to use, copy, modify, and/or distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * This software is provided 'as is' and without any warranty, express or * implied. In no event shall the authors be liable for any damages arising * from the use of this software. */ #define _GNU_SOURCE #include #include #include #include #include #include #include #include int __swapcontext(ucontext_t *oucp, const ucontext_t *ucp) { #ifdef SYS_swapcontext int r; r = syscall(SYS_swapcontext, oucp, ucp, sizeof(ucontext_t)); if (r < 0) { errno = -r; return -1; } return r; #else errno = ENOSYS; return -1; #endif } extern __typeof(__swapcontext) swapcontext __attribute__((weak, __alias__("__swapcontext")));