Skip to content

Change u_int32_t to uint32_t for more portable #437

Description

@complyue

u_int32_t addr

Building on SmartOS x64, I don't know why 2.8 can be built without problem, but building 3.1.1.1 encountered the following failure:

[root@hswander ~/network-3.1.1.1]# cabal -v3 v2-build
 ...
/root/network-3.1.1.1/dist-newstyle/build/x86_64-solaris/ghc-8.6.5/network-3.1.1.1/build/network.buildinfo
/opt/local/bin/gcc -m64 -fno-stack-protector -m64 /tmp/8975-4.c -o /tmp/8975-5 '-D__GLASGOW_HASKELL__=806' '-Dsolaris2_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Dsolaris2_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' -I/root/network-3.1.1.1/dist-newstyle/build/x86_64-solaris/ghc-8.6.5/network-3.1.1.1/build/autogen -I/root/network-3.1.1.1/dist-newstyle/build/x86_64-solaris/ghc-8.6.5/network-3.1.1.1/build/include -I./include -I. -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/bytestring-0.10.8.2/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/base-4.12.0.0/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/integer-gmp-1.0.2.0/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/include -lnsl -lsocket -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/bytestring-0.10.8.2 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/deepseq-1.4.4.0 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/array-0.5.3.0 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/base-4.12.0.0 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/integer-gmp-1.0.2.0 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/ghc-prim-0.5.3 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/rts
/opt/local/bin/gcc returned ExitFailure 1 with error message:
In file included from /tmp/8975-4.c:1:0:
./include/HsNet.h:96:14: error: unknown type name 'u_int32_t'; did you mean
'uint32_t'?
u_int32_t addr
^~~~~~~~~
uint32_t
/opt/local/bin/gcc -m64 -fno-stack-protector -m64 /tmp/8975-6.c -o /tmp/8975-7 -lnsl -lsocket -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/bytestring-0.10.8.2 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/deepseq-1.4.4.0 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/array-0.5.3.0 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/base-4.12.0.0 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/integer-gmp-1.0.2.0 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/ghc-prim-0.5.3 -L/opt/local/ghc8.6.5/lib/ghc-8.6.5/rts
/opt/local/bin/gcc -m64 -fno-stack-protector -m64 /tmp/8975-8.c -o /tmp/8975-9 -c '-D__GLASGOW_HASKELL__=806' '-Dsolaris2_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Dsolaris2_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' -I/root/network-3.1.1.1/dist-newstyle/build/x86_64-solaris/ghc-8.6.5/network-3.1.1.1/build/autogen -I/root/network-3.1.1.1/dist-newstyle/build/x86_64-solaris/ghc-8.6.5/network-3.1.1.1/build/include -I./include -I. -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/bytestring-0.10.8.2/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/base-4.12.0.0/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/integer-gmp-1.0.2.0/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/include
/opt/local/bin/gcc returned ExitFailure 1 with error message:
In file included from /tmp/8975-8.c:1:0:
./include/HsNet.h:96:14: error: unknown type name 'u_int32_t'; did you mean
'uint32_t'?
u_int32_t addr
^~~~~~~~~
uint32_t
/opt/local/bin/gcc -m64 -fno-stack-protector -m64 /tmp/8975-10.c -o /tmp/8975-11 -E '-D__GLASGOW_HASKELL__=806' '-Dsolaris2_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Dsolaris2_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' -I/root/network-3.1.1.1/dist-newstyle/build/x86_64-solaris/ghc-8.6.5/network-3.1.1.1/build/autogen -I/root/network-3.1.1.1/dist-newstyle/build/x86_64-solaris/ghc-8.6.5/network-3.1.1.1/build/include -I./include -I. -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/bytestring-0.10.8.2/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/base-4.12.0.0/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/integer-gmp-1.0.2.0/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/include
/opt/local/bin/gcc -m64 -fno-stack-protector -m64 /tmp/8975-12.c -o /tmp/8975-13 -c '-D__GLASGOW_HASKELL__=806' '-Dsolaris2_BUILD_OS=1' '-Dx86_64_BUILD_ARCH=1' '-Dsolaris2_HOST_OS=1' '-Dx86_64_HOST_ARCH=1' -I/root/network-3.1.1.1/dist-newstyle/build/x86_64-solaris/ghc-8.6.5/network-3.1.1.1/build/autogen -I/root/network-3.1.1.1/dist-newstyle/build/x86_64-solaris/ghc-8.6.5/network-3.1.1.1/build/include -I./include -I. -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/bytestring-0.10.8.2/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/base-4.12.0.0/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/integer-gmp-1.0.2.0/include -I/opt/local/ghc8.6.5/lib/ghc-8.6.5/include
/opt/local/bin/gcc returned ExitFailure 1 with error message:
In file included from /tmp/8975-12.c:1:0:
./include/HsNet.h:96:14: error: unknown type name 'u_int32_t'; did you mean
'uint32_t'?
u_int32_t addr
^~~~~~~~~
uint32_t
CallStack (from HasCallStack):
  die', called at ./Distribution/Simple/Configure.hs:1879:34 in Cabal-3.0.0.0-LUhNDbiv0rJB8Z6Pf9aFIJ:Distribution.Simple.Configure
  checkForeignDeps, called at ./Distribution/Simple.hs:643:7 in Cabal-3.0.0.0-LUhNDbiv0rJB8Z6Pf9aFIJ:Distribution.Simple
cabal: Bad header file: HsNet.h
The header file contains a compile error. You can re-run configure with the
verbosity flag -v3 to see the error messages from the C compiler.
 ...

I suppose uint32_t is equivalent and more portable according to https://lists.freedesktop.org/archives/release-wranglers/2004-August/000926.html

uint32_t is the form specified by the ISO/ANSI C99 standard, the
current version of the Single Unix Specification (the combined
replacement for the POSIX & XPG series of specs, and LSB 1.3.

while with caveat as said https://lists.freedesktop.org/archives/release-wranglers/2004-August/000932.html

uint32_t might be preferred, but that does not mean it is defined in
<sys/types.h> on all platforms. On Darwin one needs to use <stdint.h>
or <inttypes.h> as suggested in the Solaris 10 documentation. In any
case, <sys/types.h> is definitely not the right cross platform header
file and causes build breakage.

I can draft a PR for review if you folks agree on the change, but the source change is so small (just to remove one character), I guess major effort is to have CI on all supported platforms pass, which I have no idea where to start.

Activity

  1. kazu-yamamoto commented on Mar 16, 2020

    @kazu-yamamoto
    Collaborator

    u_int32_t was introduced before the current maintainers became maintainers. So, we don't have strong opinions about that. It looks reasonable for me to change it to uint32_t. Would you send us a PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions