Files
3proxy/src/fiber.h
T
Vladimir DubrovinandClaude Opus 5.5 ed49f9ab77 Windows: no Windows CE, no Windows 9x
Windows CE (_WINCE: WinMain() and its window, the command line made
into argv, the paths and functions it went without) and Windows 9x
(--install and --remove through the RunServices key of the registry,
which is what GetVersionEx() was asked for) are no longer built for.
--install and --remove use the Service Manager alone; Winsock 2.2 is
asked for, which WSAPoll() needs, rather than 1.1.

The service command of a configuration, deprecated, still does
nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-28 11:56:05 +03:00

60 lines
1.8 KiB
C

/*
3APA3A simplest proxy server
(c) 2002-2026 by Vladimir Dubrovin <vlad@3proxy.org>
please read License Agreement
*/
/* Fibers: stacks of their own a thread switches to and back, for a thread
to serve many clients each with code written as if it had a thread of
its own. The switch is our own where the processor is one of ours,
Windows' fibers on Windows; elsewhere there are none (WITH_FIBERS is not
defined), and each client has a thread. A fiber is resumed by the thread
it belongs to and yields back to it: fibers do not switch to each other,
nor move between threads. */
#ifndef _FIBER_H
#define _FIBER_H
#if defined _WIN32
#define FIBER_WINDOWS
#elif defined __x86_64__ && defined __LP64__
#define FIBER_X86_64
#elif defined __aarch64__ && defined __LP64__
#define FIBER_AARCH64
#elif defined __i386__
#define FIBER_I386
#elif defined __arm__
#define FIBER_ARM
#elif defined __mips__ && defined _MIPS_SIM && defined _ABIO32 && _MIPS_SIM == _ABIO32
#define FIBER_MIPS
#endif
#if defined FIBER_WINDOWS || defined FIBER_X86_64 || defined FIBER_AARCH64 || defined FIBER_I386 || defined FIBER_ARM || defined FIBER_MIPS
#define WITH_FIBERS
struct fiber {
void *sp; /* where its registers are while it does not run */
unsigned char *map; /* its stack, the guard page at the bottom */
size_t mapped;
void (*func)(void *arg); /* what it runs, NULL once returned */
void *arg;
int started;
#ifdef FIBER_WINDOWS
void *handle;
#endif
void *fake; /* AddressSanitizer's, while it does not run */
};
int fiberusable(void);
int fiberinit(struct fiber *f, size_t stacksize);
void fiberfree(struct fiber *f);
void fiberstart(struct fiber *f, void (*func)(void *arg), void *arg);
int fiberreset(struct fiber *f);
int fiberresume(struct fiber *f);
void fiberyield(void);
struct fiber *fibercurrent(void);
#endif
#endif