]> git.ipfire.org Git - thirdparty/psycopg.git/commitdiff
fix(c): fix portable endian aliases on different BSD flavours
authorDaniele Varrazzo <daniele.varrazzo@gmail.com>
Fri, 11 Mar 2022 20:07:03 +0000 (20:07 +0000)
committerDaniele Varrazzo <daniele.varrazzo@gmail.com>
Sat, 12 Mar 2022 11:41:58 +0000 (11:41 +0000)
See the commit at:
https://github.com/linux-sunxi/sunxi-tools/commit/384ff6473455da1a24b5037b358591f44f3bbf57

Close #241

docs/news.rst
psycopg_c/psycopg_c/_psycopg/endian.pxd

index f5c4a9d53f8bd57652b0de7c5bff48be94251225..6a7ac3b28bea9af22b7c7d88ee6b3541f4708328 100644 (file)
@@ -28,6 +28,7 @@ Psycopg 3.0.10
   (currently only for sync connections, :ticket:`#231`).
 - Fix `Cursor.description` after a COPY ... TO STDOUT operation
   (:ticket:`#235`).
+- Fix building on FreeBSD and likely other BSD flavours (:ticket:`#241`).
 
 
 Psycopg 3.0.9
index 1f6743da7ac8f8176d6fa91385089820ae921c0d..44e730561f6f88e6f2294e4fb950103a5bdba10d 100644 (file)
@@ -8,6 +8,8 @@ from libc.stdint cimport uint16_t, uint32_t, uint64_t
 
 cdef extern from * nogil:
     # from https://gist.github.com/panzi/6856583
+    # Improved in:
+    # https://github.com/linux-sunxi/sunxi-tools/blob/master/include/portable_endian.h
     """
 // "License": Public Domain
 // I, Mathias Panzenböck, place this file hereby into the public domain. Use it at your own risk for whatever you like.
@@ -52,22 +54,29 @@ cdef extern from * nogil:
 #      define __LITTLE_ENDIAN LITTLE_ENDIAN
 #      define __PDP_ENDIAN    PDP_ENDIAN
 
-#elif defined(__OpenBSD__)
-
-#      include <sys/endian.h>
-
-#elif defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
+#elif defined(__OpenBSD__) ||  defined(__NetBSD__) || defined(__FreeBSD__) || defined(__DragonFly__)
 
 #      include <sys/endian.h>
 
+/* For functions still missing, try to substitute 'historic' OpenBSD names */
+#ifndef be16toh
 #      define be16toh(x) betoh16(x)
+#endif
+#ifndef le16toh
 #      define le16toh(x) letoh16(x)
-
+#endif
+#ifndef be32toh
 #      define be32toh(x) betoh32(x)
+#endif
+#ifndef le32toh
 #      define le32toh(x) letoh32(x)
-
+#endif
+#ifndef be64toh
 #      define be64toh(x) betoh64(x)
+#endif
+#ifndef le64toh
 #      define le64toh(x) letoh64(x)
+#endif
 
 #elif defined(__WINDOWS__)