scroot / gopacket

Automatically exported from code.google.com/p/gopacket
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

pcap time types issue in posix envoronment #48

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Build pcap on a Linux ssytem using Musl libc not glibc

What is the expected output? What do you see instead?
Should build. Instead see
# code.google.com/p/gopacket/pcap
38: error: '__time_t' undeclared (first use in this function)
38: error: '__suseconds_t' undeclared (first use in this function)

What version of the product are you using? On what operating system?
f082f8277fb7d43caea5a997f615a33bf65fa102
on Alpine Linux 3.0.

Please provide any additional information below.

Musl libc just provides the Posix type names not any typedefs. Changing the 
conditionals as below so that the Posix types are the default seems entirely 
correct...

The following patch fixes the issue and also works fine on glibc

diff --git a/pcap/pcap.go b/pcap/pcap.go
index 76a4493..c71e613 100644
--- a/pcap/pcap.go
+++ b/pcap/pcap.go
@@ -79,9 +79,12 @@ int pcap_set_rfmon(pcap_t *p, int rfmon) {
 #elif __APPLE__
 #define gopacket_time_secs_t __darwin_time_t
 #define gopacket_time_usecs_t __darwin_suseconds_t
-#else
+#elif __GLIBC__
 #define gopacket_time_secs_t __time_t
 #define gopacket_time_usecs_t __suseconds_t
+#else
+#define gopacket_time_secs_t time_t
+#define gopacket_time_usecs_t suseconds_t
 #endif
 */
 import "C"

Original issue reported on code.google.com by jus...@specialbusservice.com on 3 Nov 2014 at 10:21

GoogleCodeExporter commented 9 years ago
Fixed, thanks!

Unfortunately, I don't have a non-glibc POSIX environment to test on, but 
please pull down the current master and let me know if you have any issues.

Original comment by gconnell@google.com on 11 Nov 2014 at 11:49