瀏覽代碼

Mildly ugly hack to force correct linkage.

tags/v0.9.3
Michael Brown 17 年之前
父節點
當前提交
5de837cc67
共有 3 個文件被更改,包括 20 次插入6 次删除
  1. 16
    6
      src/include/gpxe/socket.h
  2. 2
    0
      src/net/tcp.c
  3. 2
    0
      src/net/udp.c

+ 16
- 6
src/include/gpxe/socket.h 查看文件

@@ -12,8 +12,15 @@
12 12
  *
13 13
  * @{
14 14
  */
15
-#define SOCK_STREAM	1	/**< Connection-based, reliable streams */
16
-#define SOCK_DGRAM	2	/**< Connectionless, unreliable streams */
15
+
16
+/** Connection-based, reliable streams */
17
+#define SOCK_STREAM	( ( int ) TCP_SOCK_STREAM )
18
+extern char TCP_SOCK_STREAM[];
19
+
20
+/** Connectionless, unreliable streams */
21
+#define SOCK_DGRAM	( ( int ) UDP_SOCK_DGRAM )
22
+extern char UDP_SOCK_DGRAM[];
23
+
17 24
 /** @} */
18 25
 
19 26
 /**
@@ -24,10 +31,13 @@
24 31
  */
25 32
 static inline __attribute__ (( always_inline )) const char *
26 33
 socket_semantics_name ( int semantics ) {
27
-	switch ( semantics ) {
28
-	case SOCK_STREAM:	return "SOCK_STREAM";
29
-	case SOCK_DGRAM:	return "SOCK_DGRAM";
30
-	default:		return "SOCK_UNKNOWN";
34
+	/* Cannot use a switch() because of the {TCP_UDP}_SOCK_XXX hack */
35
+	if ( semantics == SOCK_STREAM ) {
36
+		return "SOCK_STREAM";
37
+	} else if ( semantics == SOCK_DGRAM ) {
38
+		return "SOCK_DGRAM";
39
+	} else {
40
+		return "SOCK_UNKNOWN";
31 41
 	}
32 42
 }
33 43
 

+ 2
- 0
src/net/tcp.c 查看文件

@@ -973,6 +973,8 @@ struct socket_opener tcp_socket_opener __socket_opener = {
973 973
 	.open		= tcp_open,
974 974
 };
975 975
 
976
+char TCP_SOCK_STREAM[1];
977
+
976 978
 /**
977 979
  * Open TCP URI
978 980
  *

+ 2
- 0
src/net/udp.c 查看文件

@@ -436,6 +436,8 @@ struct socket_opener udp_socket_opener __socket_opener = {
436 436
 	.open		= udp_open,
437 437
 };
438 438
 
439
+char UDP_SOCK_DGRAM[1];
440
+
439 441
 /**
440 442
  * Open UDP URI
441 443
  *

Loading…
取消
儲存