[beast/win32: 13/44] Improved errno compatibility: errno values are now also available from C.



commit 9ab2c221f5d22e4ecacc27ef112c3be9a1f22a1c
Author: Stefan Westerfeld <stefan space twc de>
Date:   Tue Sep 1 19:31:38 2009 +0200

    Improved errno compatibility: errno values are now also available from C.

 birnet/birnetos.hh      |   49 ++++++++++++++++++++++++++++++++++++++++++++--
 birnet/birnetosunix.cc  |    5 ----
 birnet/birnetoswin32.cc |    7 ++---
 sfi/sfiwrapper.cc       |    3 +-
 sfi/sfiwrapper.h        |   10 +++++++-
 5 files changed, 59 insertions(+), 15 deletions(-)
---
diff --git a/birnet/birnetos.hh b/birnet/birnetos.hh
index 8646483..5bf6947 100644
--- a/birnet/birnetos.hh
+++ b/birnet/birnetos.hh
@@ -17,11 +17,47 @@
 #ifndef __BIRNET_OS_HH__
 #define __BIRNET_OS_HH__
 
-#include <birnet/birnetutils.hh>
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <unistd.h>
 
+// some errno values are not supported by every system
+enum {
+  BIRNET_OS_ENOTBLK
+#ifdef ENOTBLK
+                    = ENOTBLK,
+#else
+                    = 1000,
+#endif
+  BIRNET_OS_ENOTSOCK
+#ifdef ENOTSOCK
+                    = ENOTSOCK,
+#else
+                    = 1001,
+#endif
+  BIRNET_OS_ELOOP
+#ifdef ELOOP
+                    = ELOOP,
+#else
+                    = 1002,
+#endif
+  BIRNET_OS_ENOMSG
+#ifdef ENOMSG
+                    = ENOMSG,
+#else
+                    = 1003,
+#endif
+  BIRNET_OS_ETXTBSY
+#ifdef ETXTBSY
+                    = ETXTBSY,
+#else
+                    = 1004,
+#endif
+};
+
+#ifdef __cplusplus
+#include <birnet/birnetutils.hh>
+
 namespace Birnet {
 
 namespace OS {
@@ -58,10 +94,17 @@ extern int OS_S_IXGRP;
 extern int OS_S_IXOTH;
 
 // some errno values are not supported by every system
-extern int OS_ENOTBLK;
-extern int OS_ENOTSOCK;
+enum {
+  OS_ENOTBLK = BIRNET_OS_ENOTBLK,
+  OS_ENOTSOCK = BIRNET_OS_ENOTSOCK,
+  OS_ELOOP = BIRNET_OS_ELOOP,
+  OS_ENOMSG = BIRNET_OS_ENOMSG,
+  OS_ETXTBSY = BIRNET_OS_ETXTBSY,
+};
 
 } // Birnet
 
+#endif /* __cplusplus */
+
 #endif /* __BIRNET_OS_HH__ */
 /* vim:set ts=8 sts=2 sw=2: */
diff --git a/birnet/birnetosunix.cc b/birnet/birnetosunix.cc
index a3616d6..a7124c9 100644
--- a/birnet/birnetosunix.cc
+++ b/birnet/birnetosunix.cc
@@ -190,10 +190,5 @@ mkdir (const char *path,
 int OS_S_IXGRP = S_IXGRP;
 int OS_S_IXOTH = S_IXOTH;
 
-// some errno values are not supported by every system
-int OS_ENOTBLK = ENOTBLK;
-int OS_ENOTSOCK = ENOTSOCK;
-
-
 } // Birnet
 
diff --git a/birnet/birnetoswin32.cc b/birnet/birnetoswin32.cc
index 4d9c39d..d3abb15 100644
--- a/birnet/birnetoswin32.cc
+++ b/birnet/birnetoswin32.cc
@@ -19,6 +19,9 @@
 #include <glib/gprintf.h>
 #include <process.h>
 #include <sys/stat.h>
+#include <errno.h>
+#include <string.h>
+#include <stdlib.h>
 
 namespace Birnet {
 namespace OS {
@@ -152,10 +155,6 @@ mkdir (const char *path,
 
 } // OS
 
-/* fake errno values */
-int OS_ENOTBLK  = 1000;
-int OS_ENOTSOCK = 1001;
-
 /* fake permissions */
 int OS_S_IXOTH = 0;
 int OS_S_IXGRP = 0;
diff --git a/sfi/sfiwrapper.cc b/sfi/sfiwrapper.cc
index b424b15..b9e8f59 100644
--- a/sfi/sfiwrapper.cc
+++ b/sfi/sfiwrapper.cc
@@ -259,7 +259,7 @@ sfi_debug_channel_destroy (SfiDebugChannel *debug_channel)
 void
 sfi_url_show (const char *url)
 {
-  return Birnet::url_show (url);
+  Birnet::url_show (url);
 }
 
 void
@@ -360,4 +360,5 @@ sfi_os_memcpy4 (uint32 *dest, const uint32 *src, size_t count)
   Birnet::OS::memcpy4 (dest, src, count);
 }
 
+
 /* vim:set ts=8 sts=2 sw=2: */
diff --git a/sfi/sfiwrapper.h b/sfi/sfiwrapper.h
index c3d43e8..5883655 100644
--- a/sfi/sfiwrapper.h
+++ b/sfi/sfiwrapper.h
@@ -285,16 +285,22 @@ void sfi_runtime_problem (char        ewran_tag,
 			  ...) BIRNET_PRINTF (6, 7);
 
 /* --- birnet OS layer --- */
-
 bool    sfi_os_stat_is_socket (mode_t mode);        /* S_ISSOCK */
 bool    sfi_os_stat_is_link (mode_t mode);          /* S_ISLNK */
 int     sfi_os_mkdir (const char *path, mode_t mode);
 void    sfi_os_memset4 (uint32 *dest, uint32 ch, size_t count);
 void    sfi_os_memcpy4 (uint32 *dest, const uint32 *src, size_t count);
 
-
 BIRNET_EXTERN_C_END();
 
+#include <birnet/birnetos.hh>
+
+#define SFI_OS_ENOTBLK    BIRNET_OS_ENOTBLK
+#define SFI_OS_ENOTSOCK   BIRNET_OS_ENOTSOCK
+#define SFI_OS_ELOOP      BIRNET_OS_ELOOP
+#define SFI_OS_ENOMSG     BIRNET_OS_ENOMSG
+#define SFI_OS_ETXTBSY    BIRNET_OS_ETXTBSY
+
 #endif /* __SFI_WRAPPER_H__ */
 
 /* vim:set ts=8 sts=2 sw=2: */



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]