ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/libcoro/coro.h
(Generate patch)

Comparing libcoro/coro.h (file contents):
Revision 1.54 by root, Fri Dec 21 04:48:17 2012 UTC vs.
Revision 1.55 by root, Sun Mar 6 06:26:21 2016 UTC

1/* 1/*
2 * Copyright (c) 2001-2012 Marc Alexander Lehmann <schmorp@schmorp.de> 2 * Copyright (c) 2001-2012,2015 Marc Alexander Lehmann <schmorp@schmorp.de>
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without modifica- 4 * Redistribution and use in source and binary forms, with or without modifica-
5 * tion, are permitted provided that the following conditions are met: 5 * tion, are permitted provided that the following conditions are met:
6 * 6 *
7 * 1. Redistributions of source code must retain the above copyright notice, 7 * 1. Redistributions of source code must retain the above copyright notice,
77 * 2011-08-08 cygwin trashes stacks, use pthreads with double stack on cygwin. 77 * 2011-08-08 cygwin trashes stacks, use pthreads with double stack on cygwin.
78 * 2012-12-04 reduce misprediction penalty for x86/amd64 assembly switcher. 78 * 2012-12-04 reduce misprediction penalty for x86/amd64 assembly switcher.
79 * 2012-12-05 experimental fiber backend (allocates stack twice). 79 * 2012-12-05 experimental fiber backend (allocates stack twice).
80 * 2012-12-07 API version 3 - add coro_stack_alloc/coro_stack_free. 80 * 2012-12-07 API version 3 - add coro_stack_alloc/coro_stack_free.
81 * 2012-12-21 valgrind stack registering was broken. 81 * 2012-12-21 valgrind stack registering was broken.
82 * 2015-12-05 experimental asm be for arm7, based on a patch by Nick Zavaritsky.
83 * use __name__ for predefined symbols, as in libecb.
84 * enable guard pages on arm, aarch64 and mips.
82 */ 85 */
83 86
84#ifndef CORO_H 87#ifndef CORO_H
85#define CORO_H 88#define CORO_H
86 89
138 * For SGI's version of Microsoft's NT ;) 141 * For SGI's version of Microsoft's NT ;)
139 * 142 *
140 * -DCORO_ASM 143 * -DCORO_ASM
141 * 144 *
142 * Hand coded assembly, known to work only on a few architectures/ABI: 145 * Hand coded assembly, known to work only on a few architectures/ABI:
143 * GCC + x86/IA32 and amd64/x86_64 + GNU/Linux and a few BSDs. Fastest choice, 146 * GCC + arm7/x86/IA32/amd64/x86_64 + GNU/Linux and a few BSDs. Fastest
144 * if it works. 147 * choice, if it works.
145 * 148 *
146 * -DCORO_PTHREAD 149 * -DCORO_PTHREAD
147 * 150 *
148 * Use the pthread API. You have to provide <pthread.h> and -lpthread. 151 * Use the pthread API. You have to provide <pthread.h> and -lpthread.
149 * This is likely the slowest backend, and it also does not support fork(), 152 * This is likely the slowest backend, and it also does not support fork(),
297 300
298#if !defined CORO_LOSER && !defined CORO_UCONTEXT \ 301#if !defined CORO_LOSER && !defined CORO_UCONTEXT \
299 && !defined CORO_SJLJ && !defined CORO_LINUX \ 302 && !defined CORO_SJLJ && !defined CORO_LINUX \
300 && !defined CORO_IRIX && !defined CORO_ASM \ 303 && !defined CORO_IRIX && !defined CORO_ASM \
301 && !defined CORO_PTHREAD && !defined CORO_FIBER 304 && !defined CORO_PTHREAD && !defined CORO_FIBER
302# if defined WINDOWS && (defined __i386 || (__x86_64 || defined _M_IX86 || defined _M_AMD64) 305# if defined WINDOWS && (defined __i386__ || (__x86_64__ || defined _M_IX86 || defined _M_AMD64)
303# define CORO_ASM 1 306# define CORO_ASM 1
304# elif defined WINDOWS || defined _WIN32 307# elif defined WINDOWS || defined _WIN32
305# define CORO_LOSER 1 /* you don't win with windoze */ 308# define CORO_LOSER 1 /* you don't win with windoze */
306# elif __linux && (__i386 || (__x86_64 && !__ILP32)) 309# elif __linux && (__i386__ || (__x86_64__ && !__ILP32__) || (__arm__ && __ARCH_ARCH == 7))
307# define CORO_ASM 1 310# define CORO_ASM 1
308# elif defined HAVE_UCONTEXT_H 311# elif defined HAVE_UCONTEXT_H
309# define CORO_UCONTEXT 1 312# define CORO_UCONTEXT 1
310# elif defined HAVE_SETJMP_H && defined HAVE_SIGALTSTACK 313# elif defined HAVE_SETJMP_H && defined HAVE_SIGALTSTACK
311# define CORO_SJLJ 1 314# define CORO_SJLJ 1
373struct coro_context 376struct coro_context
374{ 377{
375 void **sp; /* must be at offset 0 */ 378 void **sp; /* must be at offset 0 */
376}; 379};
377 380
381#if __i386__ || __x86_64__
378void __attribute__ ((__noinline__, __regparm__(2))) 382void __attribute__ ((__noinline__, __regparm__(2)))
383#else
384void __attribute__ ((__noinline__))
385#endif
379coro_transfer (coro_context *prev, coro_context *next); 386coro_transfer (coro_context *prev, coro_context *next);
380 387
381# define coro_destroy(ctx) (void *)(ctx) 388# define coro_destroy(ctx) (void *)(ctx)
382 389
383#elif CORO_PTHREAD 390#elif CORO_PTHREAD

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines