… | |
… | |
515 | |
515 | |
516 | #ifndef ECB_H |
516 | #ifndef ECB_H |
517 | #define ECB_H |
517 | #define ECB_H |
518 | |
518 | |
519 | /* 16 bits major, 16 bits minor */ |
519 | /* 16 bits major, 16 bits minor */ |
520 | #define ECB_VERSION 0x00010002 |
520 | #define ECB_VERSION 0x00010003 |
521 | |
521 | |
522 | #ifdef _WIN32 |
522 | #ifdef _WIN32 |
523 | typedef signed char int8_t; |
523 | typedef signed char int8_t; |
524 | typedef unsigned char uint8_t; |
524 | typedef unsigned char uint8_t; |
525 | typedef signed short int16_t; |
525 | typedef signed short int16_t; |
… | |
… | |
549 | #else |
549 | #else |
550 | #define ECB_PTRSIZE 4 |
550 | #define ECB_PTRSIZE 4 |
551 | #endif |
551 | #endif |
552 | #endif |
552 | #endif |
553 | |
553 | |
|
|
554 | /* work around x32 idiocy by defining proper macros */ |
|
|
555 | #if __x86_64 || _M_AMD64 |
|
|
556 | #if __ILP32 |
|
|
557 | #define ECB_AMD64_X32 1 |
|
|
558 | #else |
|
|
559 | #define ECB_AMD64 1 |
|
|
560 | #endif |
|
|
561 | #endif |
|
|
562 | |
554 | /* many compilers define _GNUC_ to some versions but then only implement |
563 | /* many compilers define _GNUC_ to some versions but then only implement |
555 | * what their idiot authors think are the "more important" extensions, |
564 | * what their idiot authors think are the "more important" extensions, |
556 | * causing enormous grief in return for some better fake benchmark numbers. |
565 | * causing enormous grief in return for some better fake benchmark numbers. |
557 | * or so. |
566 | * or so. |
558 | * we try to detect these and simply assume they are not gcc - if they have |
567 | * we try to detect these and simply assume they are not gcc - if they have |
… | |
… | |
618 | #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad" : : : "memory") |
627 | #define ECB_MEMORY_FENCE_ACQUIRE __asm__ __volatile__ ("membar #LoadStore | #LoadLoad" : : : "memory") |
619 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore | #StoreStore") |
628 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("membar #LoadStore | #StoreStore") |
620 | #elif defined __s390__ || defined __s390x__ |
629 | #elif defined __s390__ || defined __s390x__ |
621 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("bcr 15,0" : : : "memory") |
630 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("bcr 15,0" : : : "memory") |
622 | #elif defined __mips__ |
631 | #elif defined __mips__ |
|
|
632 | /* GNU/Linux emulates sync on mips1 architectures, so we force it's use */ |
|
|
633 | /* anybody else who still uses mips1 is supposed to send in their version, with detection code. */ |
623 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("sync" : : : "memory") |
634 | #define ECB_MEMORY_FENCE __asm__ __volatile__ (".set mips2; sync; .set mips0" : : : "memory") |
624 | #elif defined __alpha__ |
635 | #elif defined __alpha__ |
625 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mb" : : : "memory") |
636 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("mb" : : : "memory") |
626 | #elif defined __hppa__ |
637 | #elif defined __hppa__ |
627 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory") |
638 | #define ECB_MEMORY_FENCE __asm__ __volatile__ ("" : : : "memory") |
628 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("") |
639 | #define ECB_MEMORY_FENCE_RELEASE __asm__ __volatile__ ("") |
… | |
… | |
2095 | ev_syserr ("(libev) error creating signal/async pipe"); |
2106 | ev_syserr ("(libev) error creating signal/async pipe"); |
2096 | |
2107 | |
2097 | fd_intern (fds [0]); |
2108 | fd_intern (fds [0]); |
2098 | } |
2109 | } |
2099 | |
2110 | |
2100 | fd_intern (fds [1]); |
|
|
2101 | |
|
|
2102 | evpipe [0] = fds [0]; |
2111 | evpipe [0] = fds [0]; |
2103 | |
2112 | |
2104 | if (evpipe [1] < 0) |
2113 | if (evpipe [1] < 0) |
2105 | evpipe [1] = fds [1]; /* first call, set write fd */ |
2114 | evpipe [1] = fds [1]; /* first call, set write fd */ |
2106 | else |
2115 | else |
… | |
… | |
2111 | /* so must not be executed on windows */ |
2120 | /* so must not be executed on windows */ |
2112 | |
2121 | |
2113 | dup2 (fds [1], evpipe [1]); |
2122 | dup2 (fds [1], evpipe [1]); |
2114 | close (fds [1]); |
2123 | close (fds [1]); |
2115 | } |
2124 | } |
|
|
2125 | |
|
|
2126 | fd_intern (evpipe [1]); |
2116 | |
2127 | |
2117 | ev_io_set (&pipe_w, evpipe [0] < 0 ? evpipe [1] : evpipe [0], EV_READ); |
2128 | ev_io_set (&pipe_w, evpipe [0] < 0 ? evpipe [1] : evpipe [0], EV_READ); |
2118 | ev_io_start (EV_A_ &pipe_w); |
2129 | ev_io_start (EV_A_ &pipe_w); |
2119 | ev_unref (EV_A); /* watcher should not keep loop alive */ |
2130 | ev_unref (EV_A); /* watcher should not keep loop alive */ |
2120 | } |
2131 | } |