Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit e93d31f

Browse files
committed
init: Fix compilation.
1 parent 61cabd2 commit e93d31f

1 file changed

Lines changed: 18 additions & 10 deletions

File tree

src/init.c

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -36,26 +36,30 @@
3636
#endif
3737

3838
#if defined(_WIN32) && defined(_MSC_VER) && defined(LIBSSH_STATIC)
39+
# ifdef read
40+
# undef read
41+
# define BACKUP_READ
42+
# endif
3943
# define CONSTRUCTOR_ATTRIBUTE_(_func,p) static void _func(void); \
4044
static int _func ## _wrapper(void) { _func(); return 0; } \
4145
__pragma(section(".CRT$XCU",read)) \
4246
__declspec(allocate(".CRT$XCU")) int (* _func##_)(void) = _func ## _wrapper; \
4347
__pragma(comment(linker,"/include:" p #_func "_"))
44-
#ifdef _WIN64
45-
#define CONSTRUCTOR_ATTRIBUTE(f) CONSTRUCTOR_ATTRIBUTE_(f,"")
46-
#else
47-
#define CONSTRUCTOR_ATTRIBUTE(f) CONSTRUCTOR_ATTRIBUTE_(f,"_")
48-
#endif
48+
# ifdef _WIN64
49+
# define CONSTRUCTOR_ATTRIBUTE(f) CONSTRUCTOR_ATTRIBUTE_(f,"")
50+
# else
51+
# define CONSTRUCTOR_ATTRIBUTE(f) CONSTRUCTOR_ATTRIBUTE_(f,"_")
52+
# endif
4953
# define DESTRUCTOR_ATTRIBUTE_(_func,p) static void _func(void); \
5054
static int _func ## _constructor(void) { atexit (_func); return 0; } \
5155
__pragma(section(".CRT$XCU",read)) \
5256
__declspec(allocate(".CRT$XCU")) int (* _func##_)(void) = _func ## _constructor; \
5357
__pragma(comment(linker,"/include:" p #_func "_"))
54-
#ifdef _WIN64
55-
#define DESTRUCTOR_ATTRIBUTE(f) DESTRUCTOR_ATTRIBUTE_(f,"")
56-
#else
57-
#define DESTRUCTOR_ATTRIBUTE(f) DESTRUCTOR_ATTRIBUTE_(f,"_")
58-
#endif
58+
# ifdef _WIN64
59+
# define DESTRUCTOR_ATTRIBUTE(f) DESTRUCTOR_ATTRIBUTE_(f,"")
60+
# else
61+
# define DESTRUCTOR_ATTRIBUTE(f) DESTRUCTOR_ATTRIBUTE_(f,"_")
62+
# endif
5963
#else
6064
#ifdef HAVE_CONSTRUCTOR_ATTRIBUTE
6165
#define CONSTRUCTOR_ATTRIBUTE(_func) void _func(void) __attribute__((constructor))
@@ -82,6 +86,10 @@ static int _ssh_init_ret = 0;
8286
CONSTRUCTOR_ATTRIBUTE(libssh_constructor);
8387
DESTRUCTOR_ATTRIBUTE(libssh_destructor);
8488

89+
#ifdef BACKUP_READ
90+
# define read _read
91+
#endif
92+
8593
static int _ssh_init(unsigned constructor) {
8694

8795
int rc = 0;

0 commit comments

Comments
 (0)