develooper Front page | perl.perl5.porters | Postings from February 2020

cctypeinfo

Thread Next
From:
H.Merijn Brand
Date:
February 27, 2020 19:41
Subject:
cctypeinfo
Message ID:
20200227204029.72b52363@pc09.procura.nl
Looking for something completely different, I stumbled on cctypeinfo 
which seems to be part of hxtools (https://github.com/ghthor/hxtool)

https://github.com/ghthor/hxtools/blob/master/sdevel/cctypeinfo.c
written by Jan Engelhardt, 2011

It worked almost out-of-teh box on Linux (of course), but failed to
compile on AIX 5.2 and all mu HP-UX flavors

I've taken the liberty to create a perl script that generates this
C-source, compiles it and runs the binary, eventually giving the same
results as the original program (and a bit more), but now working on
all the systems I tried it on.

The perl script has options to keep the generated source and/or the
compiled binary.

Is this something useful to add to Porting/ ?
(I'm still working on the aligned fail which shows as 99999)

$ cctypeinfo.pl --help
usage: cctypeinfo.pl [-c cc] [-f cflags] [-s x.c] [-B x] [-C] [-v[#]]
    -c cc     --cc=cc       Specify C-compiler
    -f flags  --cflags=f    Specify compiler flags respects $CFLAGS or $CCFLAGS
    -s file   --c-file=f    Specify C-filename to use (kept when done)
    -B file   --bin=f       Specify binary name       (kept when done)
    -C        --csv         Generate CSV instead of plain text
    -v[1]     --verbose[=1] Set verbosity

$ time cctypeinfo.pl -B test-ccti
Checking for header netinet/in.h
Checking for header stddef.h
Checking for header stdint.h
Checking for header stdio.h
Checking for header stdlib.h
Checking for header sys/_inttypes.h
Checking for header sys/socket.h
Checking for header sys/stat.h
Checking for header sys/types.h
Checking for header wchar.h
Checking for header xwobble.Jrr4989.h
Checking for type char
Checking for type short
Checking for type int
Checking for type long
Checking for type float
Checking for type double
Checking for type intptr_t
Checking for type should_fail
Checking for type size_t
Checking for type wchar_t
Checking for type off_t
Checking for type loff_t
Checking for type uint8_t
Checking for type uint16_t
Checking for type uint32_t
Checking for type uint64_t
Checking for type mode_t
Checking for type time_t
Checking for type unsigned char
Checking for type unsigned short
Checking for type unsigned long
Checking for type unsigned long long
Checking for type long long
Checking for type long double
Checking for type void *
Checking for type void (*)(void)
Checking for type struct x16
Checking for type struct x32
Checking for type struct x64
Checking for type struct stat
Checking for type struct timespec
Checking for type struct sockaddr
Checking for type struct sockaddr_in
Checking for type struct sockaddr_in6
Checking for type struct sockaddr_storage
                   TYPE   SIZEOF  ALIGNOF
                   char        1        1
                  short        2        2
                    int        4        4
                   long        8        8
                  float        4        4
                 double        8        8
               intptr_t        8        8
                 size_t        8        8
                wchar_t        4        4
                  off_t        8        8
                 loff_t        8        8
                uint8_t        1        1
               uint16_t        2        2
               uint32_t        4        4
               uint64_t        8        8
                 mode_t        4        4
                 time_t        8        8
          unsigned char        1        1
         unsigned short        2        2
          unsigned long        8        8
     unsigned long long        8        8
              long long        8        8
            long double       16       16
                 void *        8        8
         void (*)(void)        8        8
             struct x16        4        2
             struct x32        8        4
             struct x64       16        8
            struct stat      144        8
        struct timespec       16        8
        struct sockaddr       16        2
     struct sockaddr_in       16        4
    struct sockaddr_in6       28        4
struct sockaddr_storage      128        8

This is a little-endian architecture.
0x1122334455667788 is stored as 0x8877665544332211
2.278u 0.898s 0:03.17 99.6%     0+0k 0+4544io 0pf+0w

$ time test-ccti
                   TYPE   SIZEOF  ALIGNOF
                   char        1        1
                  short        2        2
                    int        4        4
                   long        8        8
                  float        4        4
                 double        8        8
               intptr_t        8        8
                 size_t        8        8
                wchar_t        4        4
                  off_t        8        8
                 loff_t        8        8
                uint8_t        1        1
               uint16_t        2        2
               uint32_t        4        4
               uint64_t        8        8
                 mode_t        4        4
                 time_t        8        8
          unsigned char        1        1
         unsigned short        2        2
          unsigned long        8        8
     unsigned long long        8        8
              long long        8        8
            long double       16       16
                 void *        8        8
         void (*)(void)        8        8
             struct x16        4        2
             struct x32        8        4
             struct x64       16        8
            struct stat      144        8
        struct timespec       16        8
        struct sockaddr       16        2
     struct sockaddr_in       16        4
    struct sockaddr_in6       28        4
struct sockaddr_storage      128        8

This is a little-endian architecture.
0x1122334455667788 is stored as 0x8877665544332211
0.000u 0.000s 0:00.00 0.0%      0+0k 0+0io 0pf+0w

HP-UX 11.31$ cctypeinfo.pl -v0 -f "-Ae +DD64 -z +Z -s" -B cctypeinfo64
                   TYPE   SIZEOF  ALIGNOF
                   char        1        1
                  short        2        2
                    int        4        4
                   long        8        8
                  float        4        4
                 double        8        8
               intptr_t        8        8
                 size_t        8        8
                wchar_t        4        4
                  off_t        8        8
                 loff_t -- not defined --
                uint8_t        1        1
               uint16_t        2        2
               uint32_t        4        4
               uint64_t        8        8
                 mode_t        2        2
                 time_t        8        8
          unsigned char        1        1
         unsigned short        2        2
          unsigned long        8        8
     unsigned long long        8        8
              long long        8        8
            long double       16       16
                 void *        8        8
         void (*)(void)        8    99999
             struct x16        4        2
             struct x32        8        4
             struct x64       16        8
            struct stat      160        8
        struct timespec       16        8
        struct sockaddr       16        2
     struct sockaddr_in       16        4
    struct sockaddr_in6       28        4
struct sockaddr_storage      256        8

This is a big-endian architecture.
0x1122334455667788 is stored as 0x1122334455667788

HP-UX 11.11/PA $ cctypeinfo.pl -v0 --cc=gcc -f "-std=c99"
                   TYPE   SIZEOF  ALIGNOF
                   char        1        1
                  short        2        2
                    int        4        4
                   long        8        8
                  float        4        4
                 double        8        8
               intptr_t        8        8
                 size_t        8        8
                wchar_t        4        4
                  off_t        8        8
                 loff_t -- not defined --
                uint8_t        1        1
               uint16_t        2        2
               uint32_t        4        4
               uint64_t        8        8
                 mode_t        2        2
                 time_t        8        8
          unsigned char        1        1
         unsigned short        2        2
          unsigned long        8        8
     unsigned long long        8        8
              long long        8        8
            long double       16       16
                 void *        8        8
         void (*)(void)        8        8
             struct x16        4        2
             struct x32        8        4
             struct x64       16        8
            struct stat -- not defined --
        struct timespec -- not defined --
        struct sockaddr -- not defined --
     struct sockaddr_in -- not defined --
    struct sockaddr_in6 -- not defined --
struct sockaddr_storage -- not defined --

This is a big-endian architecture.
0x1122334455667788 is stored as 0x1122334455667788


-- 
H.Merijn Brand  http://tux.nl   Perl Monger  http://amsterdam.pm.org/
using perl5.00307 .. 5.31      porting perl5 on HP-UX, AIX, and Linux
https://useplaintext.email  https://tux.nl  http://www.test-smoke.org
http://qa.perl.org   http://www.goldmark.org/jeff/stupid-disclaimers/

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About