Changeset 3f7fe9e in mainline


Ignore:
Timestamp:
2018-10-01T18:36:42Z (5 years ago)
Author:
Jiří Zárevúcky <jiri.zarevucky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5cef315
Parents:
1938b381
git-author:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-09-29 16:13:55)
git-committer:
Jiří Zárevúcky <jiri.zarevucky@…> (2018-10-01 18:36:42)
Message:

Clean up headers

Depends on <limits.h> and <stdint.h> being provided, which is a step up from
depending on mostly undocumented predefined macros.
In principle, <limits.h> and <stdint.h> mostly describe properties of
the compiler, so even though we depend on certain values for their contents,
actually defining them in the library is kind of reversal of concerns.

Files:
6 deleted
20 edited
2 moved

Legend:

Unmodified
Added
Removed
  • abi/include/_bits/all.h

    r1938b381 r3f7fe9e  
    4141#define _BITS_ALL_H_
    4242
    43 #include <_bits/inttypes.h>
    44 #include <_bits/limits.h>
     43#include <inttypes.h>
     44#include <limits.h>
     45#include <stddef.h>
     46
    4547#include <_bits/native.h>
    46 #include <_bits/ptrdiff_t.h>
    47 #include <_bits/size_t.h>
    4848#include <_bits/ssize_t.h>
    49 #include <_bits/stdint.h>
    50 #include <_bits/wchar_t.h>
    5149#include <_bits/wint_t.h>
    5250
  • abi/include/_bits/int128_t.h

    r1938b381 r3f7fe9e  
    11/*
    2  * Copyright (c) 2006 Josef Cejka
     2 * Copyright (c) 2018 CZ.NIC, z.s.p.o.
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libc
     29/*
     30 * Authors:
     31 *      Jiří Zárevúcky (jzr) <zarevucky.jiri@gmail.com>
     32 */
     33
     34/** @addtogroup bits
    3035 * @{
    3136 */
    3237/** @file
     38 * Define nonstandard 128-bit types if they are supported by the compiler.
     39 * GCC only provides this on some architectures. We use it on IA-64.
    3340 */
    3441
    35 #ifndef LIBC_STDINT_H_
    36 #define LIBC_STDINT_H_
     42#ifndef _BITS_INT128_T_H_
     43#define _BITS_INT128_T_H_
    3744
    38 #ifdef __cplusplus
    39 extern "C" {
    40 #endif
    41 
    42 #include <_bits/stdint.h>
    43 
    44 #ifdef __cplusplus
    45 }
     45#ifdef __SIZEOF_INT128__
     46typedef __int128 int128_t;
     47typedef unsigned __int128 uint128_t;
    4648#endif
    4749
  • abi/include/inttypes.h

    r1938b381 r3f7fe9e  
    11/*
    2  * Copyright (c) 2010 Jiri Svoboda
     2 * Copyright (c) 2017 CZ.NIC, z.s.p.o.
    33 * All rights reserved.
    44 *
     
    2727 */
    2828
    29 /** @addtogroup libc
     29/*
     30 * Authors:
     31 *      Jiří Zárevúcky (jzr) <zarevucky.jiri@gmail.com>
     32 */
     33
     34/** @addtogroup bits
    3035 * @{
    3136 */
     
    3338 */
    3439
    35 #ifndef LIBC_INTTYPES_H_
    36 #define LIBC_INTTYPES_H_
     40#ifndef _BITS_INTTYPES_H_
     41#define _BITS_INTTYPES_H_
     42
     43#include <stdint.h>
     44#include <_bits/wchar_t.h>
     45
     46/*
     47 * We assume the -helenos target is in use, which means the following assignment:
     48 *
     49 *            32b             64b
     50 * int8_t     unsigned char   unsigned char
     51 * int16_t    short           short
     52 * int32_t    int             int
     53 * int64_t    long long       long
     54 * intptr_t   int             long
     55 * size_t     unsigned int    unsigned long
     56 * ptrdiff_t  int             long
     57 * intmax_t   long long       long long
     58 *
     59 * intleast*_t    same as int*_t
     60 * intfast*_t     at least int, otherwise same as int*_t
     61 */
     62
     63#define PRId8       "hhd"
     64#define PRIdLEAST8  "hhd"
     65#define PRIdFAST8   "d"
     66
     67#define PRIi8       "hhi"
     68#define PRIiLEAST8  "hhi"
     69#define PRIiFAST8   "i"
     70
     71#define PRIo8       "hho"
     72#define PRIoLEAST8  "hho"
     73#define PRIoFAST8   "o"
     74
     75#define PRIu8       "hhu"
     76#define PRIuLEAST8  "hhu"
     77#define PRIuFAST8   "u"
     78
     79#define PRIx8       "hhx"
     80#define PRIxLEAST8  "hhx"
     81#define PRIxFAST8   "x"
     82
     83#define PRIX8       "hhX"
     84#define PRIXLEAST8  "hhX"
     85#define PRIXFAST8   "X"
     86
     87#define SCNd8       "hhd"
     88#define SCNdLEAST8  "hhd"
     89#define SCNdFAST8   "d"
     90
     91#define SCNi8       "hhi"
     92#define SCNiLEAST8  "hhi"
     93#define SCNiFAST8   "i"
     94
     95#define SCNo8       "hho"
     96#define SCNoLEAST8  "hho"
     97#define SCNoFAST8   "o"
     98
     99#define SCNu8       "hhu"
     100#define SCNuLEAST8  "hhu"
     101#define SCNuFAST8   "u"
     102
     103#define SCNx8       "hhx"
     104#define SCNxLEAST8  "hhx"
     105#define SCNxFAST8   "x"
     106
     107#define PRId16       "hd"
     108#define PRIdLEAST16  "hd"
     109#define PRIdFAST16   "d"
     110
     111#define PRIi16       "hi"
     112#define PRIiLEAST16  "hi"
     113#define PRIiFAST16   "i"
     114
     115#define PRIo16       "ho"
     116#define PRIoLEAST16  "ho"
     117#define PRIoFAST16   "o"
     118
     119#define PRIu16       "hu"
     120#define PRIuLEAST16  "hu"
     121#define PRIuFAST16   "u"
     122
     123#define PRIx16       "hx"
     124#define PRIxLEAST16  "hx"
     125#define PRIxFAST16   "x"
     126
     127#define PRIX16       "hX"
     128#define PRIXLEAST16  "hX"
     129#define PRIXFAST16   "X"
     130
     131#define SCNd16       "hd"
     132#define SCNdLEAST16  "hd"
     133#define SCNdFAST16   "d"
     134
     135#define SCNi16       "hi"
     136#define SCNiLEAST16  "hi"
     137#define SCNiFAST16   "i"
     138
     139#define SCNo16       "ho"
     140#define SCNoLEAST16  "ho"
     141#define SCNoFAST16   "o"
     142
     143#define SCNu16       "hu"
     144#define SCNuLEAST16  "hu"
     145#define SCNuFAST16   "u"
     146
     147#define SCNx16       "hx"
     148#define SCNxLEAST16  "hx"
     149#define SCNxFAST16   "x"
     150
     151#define PRId32       "d"
     152#define PRIdLEAST32  "d"
     153#define PRIdFAST32   "d"
     154
     155#define PRIi32       "i"
     156#define PRIiLEAST32  "i"
     157#define PRIiFAST32   "i"
     158
     159#define PRIo32       "o"
     160#define PRIoLEAST32  "o"
     161#define PRIoFAST32   "o"
     162
     163#define PRIu32       "u"
     164#define PRIuLEAST32  "u"
     165#define PRIuFAST32   "u"
     166
     167#define PRIx32       "x"
     168#define PRIxLEAST32  "x"
     169#define PRIxFAST32   "x"
     170
     171#define PRIX32       "X"
     172#define PRIXLEAST32  "X"
     173#define PRIXFAST32   "X"
     174
     175#define SCNd32       "d"
     176#define SCNdLEAST32  "d"
     177#define SCNdFAST32   "d"
     178
     179#define SCNi32       "i"
     180#define SCNiLEAST32  "i"
     181#define SCNiFAST32   "i"
     182
     183#define SCNo32       "o"
     184#define SCNoLEAST32  "o"
     185#define SCNoFAST32   "o"
     186
     187#define SCNu32       "u"
     188#define SCNuLEAST32  "u"
     189#define SCNuFAST32   "u"
     190
     191#define SCNx32       "x"
     192#define SCNxLEAST32  "x"
     193#define SCNxFAST32   "x"
     194
     195#if INTPTR_MAX == 0x7fffffff
     196
     197#define PRIdPTR  "d"
     198#define PRIiPTR  "i"
     199#define PRIoPTR  "o"
     200#define PRIuPTR  "u"
     201#define PRIxPTR  "x"
     202#define PRIXPTR  "X"
     203#define SCNdPTR  "d"
     204#define SCNiPTR  "i"
     205#define SCNoPTR  "o"
     206#define SCNuPTR  "u"
     207#define SCNxPTR  "x"
     208
     209#define PRId64       "lld"
     210#define PRIdLEAST64  "lld"
     211#define PRIdFAST64   "lld"
     212
     213#define PRIi64       "lli"
     214#define PRIiLEAST64  "lli"
     215#define PRIiFAST64   "lli"
     216
     217#define PRIo64       "llo"
     218#define PRIoLEAST64  "llo"
     219#define PRIoFAST64   "llo"
     220
     221#define PRIu64       "llu"
     222#define PRIuLEAST64  "llu"
     223#define PRIuFAST64   "llu"
     224
     225#define PRIx64       "llx"
     226#define PRIxLEAST64  "llx"
     227#define PRIxFAST64   "llx"
     228
     229#define PRIX64       "llX"
     230#define PRIXLEAST64  "llX"
     231#define PRIXFAST64   "llX"
     232
     233#define SCNd64       "lld"
     234#define SCNdLEAST64  "lld"
     235#define SCNdFAST64   "lld"
     236
     237#define SCNi64       "lli"
     238#define SCNiLEAST64  "lli"
     239#define SCNiFAST64   "lli"
     240
     241#define SCNo64       "llo"
     242#define SCNoLEAST64  "llo"
     243#define SCNoFAST64   "llo"
     244
     245#define SCNu64       "llu"
     246#define SCNuLEAST64  "llu"
     247#define SCNuFAST64   "llu"
     248
     249#define SCNx64       "llx"
     250#define SCNxLEAST64  "llx"
     251#define SCNxFAST64   "llx"
     252
     253#else
     254
     255#define PRIdPTR  "ld"
     256#define PRIiPTR  "li"
     257#define PRIoPTR  "lo"
     258#define PRIuPTR  "lu"
     259#define PRIxPTR  "lx"
     260#define PRIXPTR  "lX"
     261#define SCNdPTR  "ld"
     262#define SCNiPTR  "li"
     263#define SCNoPTR  "lo"
     264#define SCNuPTR  "lu"
     265#define SCNxPTR  "lx"
     266
     267#define PRId64       "ld"
     268#define PRIdLEAST64  "ld"
     269#define PRIdFAST64   "ld"
     270
     271#define PRIi64       "li"
     272#define PRIiLEAST64  "li"
     273#define PRIiFAST64   "li"
     274
     275#define PRIo64       "lo"
     276#define PRIoLEAST64  "lo"
     277#define PRIoFAST64   "lo"
     278
     279#define PRIu64       "lu"
     280#define PRIuLEAST64  "lu"
     281#define PRIuFAST64   "lu"
     282
     283#define PRIx64       "lx"
     284#define PRIxLEAST64  "lx"
     285#define PRIxFAST64   "lx"
     286
     287#define PRIX64       "lX"
     288#define PRIXLEAST64  "lX"
     289#define PRIXFAST64   "lX"
     290
     291#define SCNd64       "ld"
     292#define SCNdLEAST64  "ld"
     293#define SCNdFAST64   "ld"
     294
     295#define SCNi64       "li"
     296#define SCNiLEAST64  "li"
     297#define SCNiFAST64   "li"
     298
     299#define SCNo64       "lo"
     300#define SCNoLEAST64  "lo"
     301#define SCNoFAST64   "lo"
     302
     303#define SCNu64       "lu"
     304#define SCNuLEAST64  "lu"
     305#define SCNuFAST64   "lu"
     306
     307#define SCNx64       "lx"
     308#define SCNxLEAST64  "lx"
     309#define SCNxFAST64   "lx"
     310
     311#endif
     312
     313#ifdef _HELENOS_SOURCE
     314#define UINT8_MIN   0
     315#define UINT16_MIN  0
     316#define UINT32_MIN  0
     317#define UINT64_MIN  0
     318#endif
     319
     320#define PRIdMAX  "lld"
     321#define PRIiMAX  "lli"
     322#define PRIoMAX  "llo"
     323#define PRIuMAX  "llu"
     324#define PRIxMAX  "llx"
     325#define PRIXMAX  "llX"
     326#define SCNdMAX  "lld"
     327#define SCNiMAX  "lli"
     328#define SCNoMAX  "llo"
     329#define SCNuMAX  "llu"
     330#define SCNxMAX  "llx"
    37331
    38332#ifdef __cplusplus
     
    40334#endif
    41335
    42 #include <_bits/inttypes.h>
    43 
    44 #ifndef __HELENOS_DISABLE_INTMAX__
     336typedef struct {
     337        intmax_t quot;
     338        intmax_t rem;
     339} imaxdiv_t;
     340
    45341intmax_t imaxabs(intmax_t);
    46342imaxdiv_t imaxdiv(intmax_t, intmax_t);
    47 intmax_t strtoimax(const char *__restrict__ nptr,
    48     char **__restrict__ endptr, int base);
    49 uintmax_t strtoumax(const char *__restrict__ nptr,
    50     char **__restrict__ endptr, int base);
    51 #endif
     343intmax_t strtoimax(const char *__restrict__, char **__restrict__, int);
     344uintmax_t strtoumax(const char *__restrict__, char **__restrict__, int);
    52345
    53346#ifdef __cplusplus
  • abi/include/limits.h

    r1938b381 r3f7fe9e  
    3636#define LIBC_LIMITS_H_
    3737
    38 #ifdef __cplusplus
    39 extern "C" {
     38#ifdef __GNUC__
     39/*
     40 * Default to compiler's version of limits.h, so we don't have to care about
     41 * language version and whatnot.
     42 */
     43#include_next <limits.h>
     44#else
     45
     46/* HelenOS requires 8-bit char and two's complement arithmetic. */
     47#define CHAR_BIT    8
     48#define SCHAR_MAX   0x7f
     49#define SCHAR_MIN   (-SCHAR_MAX - 1)
     50#define SHRT_MAX    0x7fff
     51#define SHRT_MIN    (-SHRT_MAX - 1)
     52#define INT_MAX     0x7fffffff
     53#define INT_MIN     (-INT_MAX - 1)
     54#define LLONG_MAX   0x7fffffffffffffffll
     55#define LLONG_MIN   (-LLONG_MAX - 1)
     56
     57#define UCHAR_MAX   0xff
     58#define USHRT_MAX   0xffff
     59#define UINT_MAX    0xffffffffu
     60#define ULLONG_MAX  0xffffffffffffffffull
     61
     62#if __STDC_VERSION__ >= 201112L
     63_Static_assert(((char)-1) < 0, "char should be signed");
    4064#endif
    4165
    42 #include <_bits/limits.h>
     66#define CHAR_MAX  SCHAR_MAX
     67#define CHAR_MIN  SCHAR_MIN
    4368
    44 #ifdef __cplusplus
    45 }
     69#ifdef __32_BITS__
     70#define LONG_MAX   0x7fffffffl
     71#define LONG_MIN   (-LONG_MAX - 1)
     72#define ULONG_MAX  0xfffffffful
     73#endif
     74
     75#ifdef __64_BITS__
     76#define LONG_MAX   0x7fffffffffffffffl
     77#define LONG_MIN   (-LONG_MAX - 1)
     78#define ULONG_MAX  0xfffffffffffffffful
     79#endif
     80
     81#endif  /* !defined(__GNUC__) */
     82
     83#undef MB_LEN_MAX
     84#define MB_LEN_MAX 4
     85
     86#define UCHAR_MIN   0
     87#define USHRT_MIN   0
     88#define UINT_MIN    (0u)
     89#define ULONG_MIN   (0ul)
     90#define ULLONG_MIN  (0ull)
     91
     92/* GCC's <limits.h> doesn't define these for C++11, even though it should. */
     93#if __cplusplus >= 201103L
     94#ifndef LLONG_MAX
     95#define LLONG_MAX  0x7fffffffffffffffll
     96#endif
     97#ifndef LLONG_MIN
     98#define LLONG_MIN  (-LLONG_MAX - 1)
     99#endif
     100#ifndef ULLONG_MAX
     101#define ULLONG_MAX  0xffffffffffffffffull
     102#endif
    46103#endif
    47104
  • boot/arch/arm32/src/main.c

    r1938b381 r3f7fe9e  
    3535
    3636#include <arch/main.h>
     37#include <arch/types.h>
    3738#include <arch/asm.h>
    3839#include <arch/mm.h>
  • boot/arch/arm32/src/mm.c

    r1938b381 r3f7fe9e  
    3838#include <arch/mm.h>
    3939#include <arch/cp15.h>
     40#include <arch/types.h>
    4041
    4142#ifdef PROCESSOR_ARCH_armv7_a
  • boot/arch/mips32/src/main.c

    r1938b381 r3f7fe9e  
    3030#include <arch/arch.h>
    3131#include <arch/asm.h>
     32#include <arch/types.h>
    3233#include <halt.h>
    3334#include <printf.h>
  • boot/arch/ppc32/include/arch/main.h

    r1938b381 r3f7fe9e  
    3333#include <balloc.h>
    3434#include <genarch/ofw_tree.h>
     35#include <arch/types.h>
    3536
    3637typedef struct {
  • boot/arch/ppc32/src/main.c

    r1938b381 r3f7fe9e  
    3030#include <arch/arch.h>
    3131#include <arch/asm.h>
     32#include <arch/types.h>
    3233#include <genarch/ofw.h>
    3334#include <genarch/ofw_tree.h>
  • boot/arch/riscv64/src/main.c

    r1938b381 r3f7fe9e  
    3232#include <arch/ucb.h>
    3333#include <arch/mm.h>
     34#include <arch/types.h>
    3435#include <version.h>
    3536#include <stddef.h>
     
    6465        bootinfo.memmap.zones[0].size = PHYSMEM_SIZE;
    6566
    66         printf("\nMemory statistics (total %llu MB, starting at %p)\n\n",
     67        printf("\nMemory statistics (total %" PRIu64 " MB, starting at %p)\n\n",
    6768            bootinfo.memmap.total >> 20, (void *) bootinfo.physmem_start);
    6869        printf(" %p: boot info structure\n", &bootinfo);
  • boot/arch/sparc64/include/arch/main.h

    r1938b381 r3f7fe9e  
    3333#include <balloc.h>
    3434#include <genarch/ofw_tree.h>
     35#include <arch/types.h>
    3536
    3637typedef struct {
  • boot/genarch/include/genarch/ofw.h

    r1938b381 r3f7fe9e  
    3333#include <stddef.h>
    3434#include <stdint.h>
     35#include <_bits/native.h>
    3536
    3637#define MEMMAP_MAX_RECORDS  32
  • kernel/arch/ia64/include/arch/context_struct.h

    r1938b381 r3f7fe9e  
    7878
    7979#include <typedefs.h>
     80#include <_bits/int128_t.h>
    8081
    8182// Only save registers that must be preserved across function calls.
  • kernel/arch/ia64/include/arch/fpu_context.h

    r1938b381 r3f7fe9e  
    3838#define FPU_CONTEXT_ALIGN 16
    3939
    40 #include <stdint.h>
     40#include <_bits/int128_t.h>
    4141
    4242#define FRS 96
  • kernel/arch/ia64/include/arch/istate_struct.h

    r1938b381 r3f7fe9e  
    8787
    8888#include <stdint.h>
     89#include <_bits/int128_t.h>
    8990
    9091#ifdef KERNEL
  • kernel/arch/ia64/include/arch/register.h

    r1938b381 r3f7fe9e  
    165165#ifndef __ASSEMBLER__
    166166
     167#include <stdint.h>
     168
    167169/** Processor Status Register. */
    168170typedef union {
  • uspace/app/bdsh/cmds/modules/sleep/sleep.c

    r1938b381 r3f7fe9e  
    6666{
    6767        errno_t ret;
    68         sec_t whole_seconds;
    69         usec_t frac_seconds;
     68        int64_t whole_seconds;
     69        int64_t frac_seconds;
    7070        const char *endptr;
    7171
  • uspace/lib/c/arch/ia64/include/libarch/fibril_context.h

    r1938b381 r3f7fe9e  
    7676
    7777#include <stdint.h>
     78#include <_bits/int128_t.h>
    7879
    7980// Only save registers that must be preserved across function calls.
  • uspace/lib/c/generic/io/io.c

    r1938b381 r3f7fe9e  
    3737#include <str.h>
    3838#include <errno.h>
     39#include <limits.h>
    3940#include <stdbool.h>
    4041#include <stdlib.h>
  • uspace/lib/c/generic/time.c

    r1938b381 r3f7fe9e  
    4444#include <ddi.h>
    4545#include <libc.h>
     46#include <limits.h>
    4647#include <stdint.h>
    4748#include <stdio.h>
  • uspace/lib/pcm/src/format.c

    r1938b381 r3f7fe9e  
    3939#include <macros.h>
    4040#include <stdio.h>
     41#include <inttypes.h>
    4142
    4243#include "format.h"
  • uspace/lib/posix/include/posix/limits.h

    r1938b381 r3f7fe9e  
    3636#define POSIX_LIMITS_H_
    3737
    38 #include <libc/limits.h>
     38#include_next <limits.h>
    3939
    40 #undef PATH_MAX
     40#ifndef PATH_MAX
    4141#define PATH_MAX 256
     42#endif
    4243
    4344#endif /* POSIX_LIMITS_H_ */
Note: See TracChangeset for help on using the changeset viewer.