Project

General

Profile

Bug #7038

users of endian.h expect __ prefixed versions of macros

Added by Richard PALO almost 4 years ago. Updated almost 4 years ago.

Status:
Closed
Priority:
Normal
Category:
lib - userland libraries
Start date:
2016-06-05
Due date:
% Done:

100%

Estimated time:
Difficulty:
Bite-size
Tags:
Gerrit CR:

Description

From 05e68aabd009acc0a22e983288780cfd51e5c8f1 Mon Sep 17 00:00:00 2001
From: Richard PALO <richard@NetBSD.org>
Date: Sun, 5 Jun 2016 17:46:42 +0200
Subject: [PATCH] fix endian symbols

---
 usr/src/head/endian.h | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/usr/src/head/endian.h b/usr/src/head/endian.h
index a5117bb..a4c351e 100644
--- a/usr/src/head/endian.h
+++ b/usr/src/head/endian.h
@@ -11,6 +11,7 @@

 /*
  * Copyright 2016 Joyent, Inc.
+ * Copyright 2016 PALO, Richard.
  */

 #ifndef _ENDIAN_H
@@ -27,18 +28,25 @@ extern "C" {
 #include <sys/isa_defs.h>
 #include <inttypes.h>

-#define    LITTLE_ENDIAN    1234
-#define    BIG_ENDIAN    4321
-#define    PDP_ENDIAN    3412
+#define    __LITTLE_ENDIAN    1234
+#define    __BIG_ENDIAN    4321
+#define    __PDP_ENDIAN    3412

 #ifdef    _LITTLE_ENDIAN
-#define    BYTE_ORDER    LITTLE_ENDIAN
+#define    __BYTE_ORDER    __LITTLE_ENDIAN
 #elif    _BIG_ENDIAN
-#define    BYTE_ORDER    BIG_ENDIAN
+#define    __BYTE_ORDER    __BIG_ENDIAN
 #else
 #error    "Unknown byte order" 
 #endif    /* _LITTLE_ENDIAN */

+#if defined(__EXTENSIONS__) || !defined(_STRICT_STDC)
+#define    LITTLE_ENDIAN    __LITTLE_ENDIAN
+#define    BIG_ENDIAN    __BIG_ENDIAN
+#define    PDP_ENDIAN    __PDP_ENDIAN
+#define    BYTE_ORDER    __BYTE_ORDER
+#endif
+
 extern uint16_t htobe16(uint16_t);
 extern uint32_t htobe32(uint32_t);
 extern uint64_t htobe64(uint64_t);
-- 
2.8.3


Files

0001-7038-fix-endian-symbols.patch (3.53 KB) 0001-7038-fix-endian-symbols.patch Richard PALO, 2016-06-06 04:46 AM

History

#1

Updated by Igor Kozhukhov almost 4 years ago

please fix test :

igor@infra-99-018:/myshare/ssd02/builds/dilos-illumos.lx$ g show cdddd40
commit cdddd4004d41da12cfe4d13437fb4ca6b973ea40
Author: Igor Kozhukhov <ikozhukhov@gmail.com>
Date:   Tue May 24 11:55:32 2016 +0300

    fix build on sparc after endian integration

diff --git a/usr/src/test/libc-tests/tests/endian.c b/usr/src/test/libc-tests/tests/endian.c
index 1165ad7..4ffab10 100644
--- a/usr/src/test/libc-tests/tests/endian.c
+++ b/usr/src/test/libc-tests/tests/endian.c
@@ -46,7 +46,7 @@ endian_fromhost(void)
        ele16 = 0x1122;
        ele32 = 0x11223344UL;
        ele64 = 0x1122334455667788ULL;
-#elif  _BIG_ENDIAN
+#elif  defined(_BIG_ENDIAN)
        ele16 = 0x2211;
        ele32 = 0x44332211UL;
        ele64 = 0x8877665544332211ULL;
@@ -86,7 +86,7 @@ endian_frombig(void)
        e16 = 0x2211;
        e32 = 0x44332211UL;
        e64 = 0x8877665544332211ULL;
-#elif  _BIG_ENDIAN
+#elif  defined(_BIG_ENDIAN)
        e16 = 0x1122;
        e32 = 0x11223344UL;
        e64 = 0x1122334455667788ULL;
@@ -124,7 +124,7 @@ endian_fromlittle(void)
        e16 = 0x1122;
        e32 = 0x11223344UL;
        e64 = 0x1122334455667788ULL;
-#elif  _BIG_ENDIAN
+#elif  defined(_BIG_ENDIAN)
        e16 = 0x2211;
        e32 = 0x44332211UL;
        e64 = 0x8877665544332211ULL;

it failed with build on SPARC

#2

Updated by Igor Kozhukhov almost 4 years ago

Richard PALO wrote:

[...]

also please fix header at:
- #elif _BIG_ENDIAN
to
+#elif defined(_BIG_ENDIAN)

because it failed on SPARC

#3

Updated by Robert Mustacchi almost 4 years ago

Igor, please file a separate bug for sparc build issues. If you had filed it, we could have gotten that fixed already.

Richard, please actually add the original description of this. Otherwise this has no context and makes very little sense.

#4

Updated by Richard PALO almost 4 years ago

6790 want suite of endian(3C) functions breaks mozilla which expects <endian.h> to be able to do the following in jscpucfg.h:

#elif defined(JS_HAVE_ENDIAN_H)
# include <endian.h>

# if defined(__BYTE_ORDER)
#  if __BYTE_ORDER == __LITTLE_ENDIAN
#   define IS_LITTLE_ENDIAN 1
#   undef  IS_BIG_ENDIAN
#  elif __BYTE_ORDER == __BIG_ENDIAN
#   undef  IS_LITTLE_ENDIAN
#   define IS_BIG_ENDIAN 1
#  endif
# else /* !defined(__BYTE_ORDER) */
#  error "endian.h does not define __BYTE_ORDER. Cannot determine endianness." 
# endif

looks like the '__' prefixed form should perhaps be defined by default, and the standard
#if ! defined (_STRICT_STDC) || defined (__EXTENSIONS__)
whatnot be used for the defs without the prefix.

#5

Updated by Richard PALO almost 4 years ago

  • File 0001-7038-fix-endian-symbols.patch added
#6

Updated by Robert Mustacchi almost 4 years ago

As I've mentioned elsewhere, I don't believe that the use of the guards here is correct and even if it is, you've used the incorrect tests. I'll be putting out a fix for this on developer along with 7043 as I had already put something together when this first came up before you had put together a patch and we can hash it out there.

Note, I've also updated the synopsis to more accurately reflect the problem of not having versions of the symbols with the double underscores.

#7

Updated by Robert Mustacchi almost 4 years ago

  • Subject changed from fix endian.h symbols to users of endian.h expect __ prefixed versions of macros
  • Category set to lib - userland libraries
  • Assignee set to Robert Mustacchi
  • % Done changed from 0 to 90
  • Difficulty changed from Medium to Bite-size
  • Tags deleted (needs-triage)
#8

Updated by Richard PALO almost 4 years ago

  • File 0001-7038-fix-endian-symbols.patch added
#9

Updated by Richard PALO almost 4 years ago

  • File deleted (0001-7038-fix-endian-symbols.patch)
#11

Updated by Richard PALO almost 4 years ago

  • File deleted (0001-7038-fix-endian-symbols.patch)
#12

Updated by Electric Monk almost 4 years ago

  • Status changed from New to Closed
  • % Done changed from 90 to 100

git commit cc366bfc297550eb10cd5f677d98c8d206eca4f1

commit  cc366bfc297550eb10cd5f677d98c8d206eca4f1
Author: Robert Mustacchi <rm@joyent.com>
Date:   2016-07-22T16:02:18.000Z

    7038 users of endian.h expect __ prefixed versions of macros
    7043 endian.h uses bad macros for _BIG_ENDIAN
    Reviewed by: Igor Kozhukhov <ikozhukhov@gmail.com>
    Reviewed by: Richard PALO <richard@netbsd.org>
    Approved by: Dan McDonald <danmcd@omniti.com>

Also available in: Atom PDF