Skip to content

Commit e00ddec

Browse files
committed
Fix freeBSD
1 parent 07f2250 commit e00ddec

4 files changed

Lines changed: 83 additions & 12 deletions

File tree

CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,12 @@ add_custom_target(
5757
)
5858
set_target_properties(generate_version PROPERTIES FOLDER tinycsocket)
5959

60-
# Header generation
60+
# Header generation (requires GNU m4 for undivert with filename)
61+
find_program(M4_EXECUTABLE gm4 m4 REQUIRED)
6162
add_custom_command(
6263
OUTPUT ${CMAKE_CURRENT_SOURCE_DIR}/include/tinycsocket.h
6364
COMMAND
64-
m4 ${CMAKE_CURRENT_SOURCE_DIR}/src/tinycsocket.h.m4 >
65+
${M4_EXECUTABLE} ${CMAKE_CURRENT_SOURCE_DIR}/src/tinycsocket.h.m4 >
6566
${CMAKE_CURRENT_SOURCE_DIR}/include/tinycsocket.h
6667
DEPENDS ${TINYCSOCKET_SRC} ${CMAKE_CURRENT_SOURCE_DIR}/src/tinycsocket.h.m4
6768
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/src

include/tinycsocket.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#ifndef TINYCSOCKET_INTERNAL_H_
3030
#define TINYCSOCKET_INTERNAL_H_
3131

32-
static const char* const TCS_VERSION_TXT = "v0.3.59";
32+
static const char* const TCS_VERSION_TXT = "v0.3.60";
3333
static const char* const TCS_LICENSE_TXT =
3434
"Copyright 2018 Markus Lindelöw\n"
3535
"\n"
@@ -191,10 +191,9 @@ typedef unsigned int TcsInterfaceId; // TODO: GUID is used for in vista at newer
191191
#elif defined(TINYCSOCKET_USE_POSIX_IMPL)
192192

193193
#if defined(TINYCSOCKET_IMPLEMENTATION) || defined(TCS_DEFINE_POSIX_MACROS)
194-
// POSIX feature test macros must be set before any system header is included.
195-
// Without these, glibc's <features.h> (pulled in by <stdbool.h>) locks in
196-
// strict C99 defaults that hide AI_PASSIVE, struct addrinfo, struct timeval,
197-
// u_short, SO_REUSEPORT, etc.
194+
// Only needed on glibc/Cygwin where -std=c99 restricts symbol visibility.
195+
// On BSD/musl, setting these RESTRICTS visibility instead of expanding it.
196+
#if defined(__linux__) || defined(__CYGWIN__)
198197
#ifndef _XOPEN_SOURCE
199198
#define _XOPEN_SOURCE 600
200199
#endif
@@ -208,6 +207,7 @@ typedef unsigned int TcsInterfaceId; // TODO: GUID is used for in vista at newer
208207
#define _DEFAULT_SOURCE
209208
#endif
210209
#endif
210+
#endif
211211

212212
typedef int TcsSocket;
213213
typedef unsigned int TcsInterfaceId;

src/tinycsocket_internal.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#ifndef TINYCSOCKET_INTERNAL_H_
2424
#define TINYCSOCKET_INTERNAL_H_
2525

26-
static const char* const TCS_VERSION_TXT = "v0.3.59";
26+
static const char* const TCS_VERSION_TXT = "v0.3.60";
2727
static const char* const TCS_LICENSE_TXT =
2828
"Copyright 2018 Markus Lindelöw\n"
2929
"\n"
@@ -185,10 +185,9 @@ typedef unsigned int TcsInterfaceId; // TODO: GUID is used for in vista at newer
185185
#elif defined(TINYCSOCKET_USE_POSIX_IMPL)
186186

187187
#if defined(TINYCSOCKET_IMPLEMENTATION) || defined(TCS_DEFINE_POSIX_MACROS)
188-
// POSIX feature test macros must be set before any system header is included.
189-
// Without these, glibc's <features.h> (pulled in by <stdbool.h>) locks in
190-
// strict C99 defaults that hide AI_PASSIVE, struct addrinfo, struct timeval,
191-
// u_short, SO_REUSEPORT, etc.
188+
// Only needed on glibc/Cygwin where -std=c99 restricts symbol visibility.
189+
// On BSD/musl, setting these RESTRICTS visibility instead of expanding it.
190+
#if defined(__linux__) || defined(__CYGWIN__)
192191
#ifndef _XOPEN_SOURCE
193192
#define _XOPEN_SOURCE 600
194193
#endif
@@ -202,6 +201,7 @@ typedef unsigned int TcsInterfaceId; // TODO: GUID is used for in vista at newer
202201
#define _DEFAULT_SOURCE
203202
#endif
204203
#endif
204+
#endif
205205

206206
typedef int TcsSocket;
207207
typedef unsigned int TcsInterfaceId;

t

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
diff --git a/include/tinycsocket.h b/include/tinycsocket.h
2+
index 5036e60..b06ef0c 100644
3+
--- a/include/tinycsocket.h
4+
+++ b/include/tinycsocket.h
5+
@@ -29,7 +29,7 @@
6+
#ifndef TINYCSOCKET_INTERNAL_H_
7+
#define TINYCSOCKET_INTERNAL_H_
8+

9+
-static const char* const TCS_VERSION_TXT = "v0.3.59";
10+
+static const char* const TCS_VERSION_TXT = "v0.3.60";
11+
static const char* const TCS_LICENSE_TXT =
12+
"Copyright 2018 Markus Lindelöw\n"
13+
"\n"
14+
@@ -191,10 +191,9 @@ typedef unsigned int TcsInterfaceId; // TODO: GUID is used for in vista at newer
15+
#elif defined(TINYCSOCKET_USE_POSIX_IMPL)
16+

17+
#if defined(TINYCSOCKET_IMPLEMENTATION) || defined(TCS_DEFINE_POSIX_MACROS)
18+
-// POSIX feature test macros must be set before any system header is included.
19+
-// Without these, glibc's <features.h> (pulled in by <stdbool.h>) locks in
20+
-// strict C99 defaults that hide AI_PASSIVE, struct addrinfo, struct timeval,
21+
-// u_short, SO_REUSEPORT, etc.
22+
+// Only needed on glibc/Cygwin where -std=c99 restricts symbol visibility.
23+
+// On BSD/musl, setting these RESTRICTS visibility instead of expanding it.
24+
+#if defined(__linux__) || defined(__CYGWIN__)
25+
#ifndef _XOPEN_SOURCE
26+
#define _XOPEN_SOURCE 600
27+
#endif
28+
@@ -208,6 +207,7 @@ typedef unsigned int TcsInterfaceId; // TODO: GUID is used for in vista at newer
29+
#define _DEFAULT_SOURCE
30+
#endif
31+
#endif
32+
+#endif
33+

34+
typedef int TcsSocket;
35+
typedef unsigned int TcsInterfaceId;
36+
diff --git a/src/tinycsocket_internal.h b/src/tinycsocket_internal.h
37+
index a2c5b27..3c4db85 100644
38+
--- a/src/tinycsocket_internal.h
39+
+++ b/src/tinycsocket_internal.h
40+
@@ -23,7 +23,7 @@
41+
#ifndef TINYCSOCKET_INTERNAL_H_
42+
#define TINYCSOCKET_INTERNAL_H_
43+

44+
-static const char* const TCS_VERSION_TXT = "v0.3.59";
45+
+static const char* const TCS_VERSION_TXT = "v0.3.60";
46+
static const char* const TCS_LICENSE_TXT =
47+
"Copyright 2018 Markus Lindelöw\n"
48+
"\n"
49+
@@ -185,10 +185,9 @@ typedef unsigned int TcsInterfaceId; // TODO: GUID is used for in vista at newer
50+
#elif defined(TINYCSOCKET_USE_POSIX_IMPL)
51+

52+
#if defined(TINYCSOCKET_IMPLEMENTATION) || defined(TCS_DEFINE_POSIX_MACROS)
53+
-// POSIX feature test macros must be set before any system header is included.
54+
-// Without these, glibc's <features.h> (pulled in by <stdbool.h>) locks in
55+
-// strict C99 defaults that hide AI_PASSIVE, struct addrinfo, struct timeval,
56+
-// u_short, SO_REUSEPORT, etc.
57+
+// Only needed on glibc/Cygwin where -std=c99 restricts symbol visibility.
58+
+// On BSD/musl, setting these RESTRICTS visibility instead of expanding it.
59+
+#if defined(__linux__) || defined(__CYGWIN__)
60+
#ifndef _XOPEN_SOURCE
61+
#define _XOPEN_SOURCE 600
62+
#endif
63+
@@ -202,6 +201,7 @@ typedef unsigned int TcsInterfaceId; // TODO: GUID is used for in vista at newer
64+
#define _DEFAULT_SOURCE
65+
#endif
66+
#endif
67+
+#endif
68+

69+
typedef int TcsSocket;
70+
typedef unsigned int TcsInterfaceId;

0 commit comments

Comments
 (0)