Skip to content

Commit

Permalink
Move integer aliases and typedefs into root.ctinteger
Browse files Browse the repository at this point in the history
  • Loading branch information
ibuclaw committed Dec 14, 2021
1 parent dba01ae commit b4930f9
Show file tree
Hide file tree
Showing 47 changed files with 135 additions and 58 deletions.
4 changes: 2 additions & 2 deletions src/build.d
Original file line number Diff line number Diff line change
Expand Up @@ -1408,7 +1408,7 @@ auto sourceFiles()
lexer: fileArray(env["D"], "
console.d entity.d errors.d file_manager.d globals.d id.d identifier.d lexer.d tokens.d utf.d
") ~ fileArray(env["ROOT"], "
array.d bitarray.d ctfloat.d file.d filename.d hash.d port.d region.d rmem.d
array.d bitarray.d ctfloat.d ctinteger.d file.d filename.d hash.d port.d region.d rmem.d
rootobject.d stringtable.d
"),
common: fileArray(env["COMMON"], "
Expand All @@ -1421,7 +1421,7 @@ auto sourceFiles()
aav.d longdouble.d man.d optional.d response.d speller.d string.d strtold.d
"),
rootHeaders: fileArray(env["ROOT"], "
array.h bitarray.h ctfloat.h dcompat.h dsystem.h file.h filename.h longdouble.h
array.h bitarray.h ctfloat.h ctinteger.h dcompat.h dsystem.h file.h filename.h longdouble.h
object.h optional.h port.h rmem.h root.h
"),
backend: fileArray(env["C"], "
Expand Down
1 change: 1 addition & 0 deletions src/dmd/aggregate.d
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import dmd.globals;
import dmd.id;
import dmd.identifier;
import dmd.mtype;
import dmd.root.ctinteger;
import dmd.tokens;
import dmd.typesem : defaultInit;
import dmd.visitor;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/argtypes_x86.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import dmd.astenums;
import dmd.declaration;
import dmd.globals;
import dmd.mtype;
import dmd.root.ctinteger;
import dmd.target;
import dmd.visitor;

Expand Down
1 change: 1 addition & 0 deletions src/dmd/astbase.d
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ struct ASTBase
import dmd.root.rootobject;
import dmd.common.outbuffer;
import dmd.root.ctfloat;
import dmd.root.ctinteger;
import dmd.root.rmem;
import dmd.root.string : toDString;
import dmd.root.stringtable;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/builtin.d
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import dmd.func;
import dmd.globals;
import dmd.mtype;
import dmd.root.ctfloat;
import dmd.root.ctinteger;
import dmd.root.stringtable;
import dmd.tokens;
import dmd.id;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/clone.d
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import dmd.identifier;
import dmd.init;
import dmd.mtype;
import dmd.opover;
import dmd.root.ctinteger;
import dmd.semantic2;
import dmd.semantic3;
import dmd.statement;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/compiler.d
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import dmd.mtype;
import dmd.parse;
import dmd.root.array;
import dmd.root.ctfloat;
import dmd.root.ctinteger;
import dmd.semantic2;
import dmd.semantic3;
import dmd.tokens;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/cond.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import dmd.identifier;
import dmd.mtype;
import dmd.typesem;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.rootobject;
import dmd.root.string;
import dmd.tokens;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/constfold.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import dmd.expression;
import dmd.globals;
import dmd.mtype;
import dmd.root.ctfloat;
import dmd.root.ctinteger;
import dmd.root.port;
import dmd.root.rmem;
import dmd.sideeffect;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/cppmangle.d
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ import dmd.mtype;
import dmd.nspace;
import dmd.root.array;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.rootobject;
import dmd.root.string;
import dmd.target;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/cppmanglewin.d
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import dmd.id;
import dmd.identifier;
import dmd.mtype;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.rootobject;
import dmd.target;
import dmd.tokens;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/ctfeexpr.d
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import dmd.func;
import dmd.globals;
import dmd.mtype;
import dmd.root.ctfloat;
import dmd.root.ctinteger;
import dmd.root.port;
import dmd.root.rmem;
import dmd.tokens;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/dcast.d
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ import dmd.mtype;
import dmd.opover;
import dmd.root.ctfloat;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.rmem;
import dmd.tokens;
import dmd.typesem;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/declaration.d
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ import dmd.initsem;
import dmd.intrange;
import dmd.mtype;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.rootobject;
import dmd.target;
import dmd.tokens;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/dinterpret.d
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import dmd.printast;
import dmd.root.rmem;
import dmd.root.array;
import dmd.root.ctfloat;
import dmd.root.ctinteger;
import dmd.root.region;
import dmd.root.rootobject;
import dmd.statement;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/dmangle.d
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ import dmd.identifier;
import dmd.mtype;
import dmd.root.ctfloat;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.aav;
import dmd.root.string;
import dmd.root.stringtable;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/dsymbol.d
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import dmd.mtype;
import dmd.nspace;
import dmd.opover;
import dmd.root.aav;
import dmd.root.ctinteger;
import dmd.root.rmem;
import dmd.root.rootobject;
import dmd.root.speller;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/dsymbolsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import dmd.nspace;
import dmd.objc;
import dmd.opover;
import dmd.parse;
import dmd.root.ctinteger;
import dmd.root.filename;
import dmd.common.outbuffer;
import dmd.root.rmem;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/dtemplate.d
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ import dmd.mtype;
import dmd.opover;
import dmd.root.array;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.rootobject;
import dmd.semantic2;
import dmd.semantic3;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/dtoh.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import dmd.errors;
import dmd.globals;
import dmd.hdrgen;
import dmd.identifier;
import dmd.root.ctinteger;
import dmd.root.filename;
import dmd.visitor;
import dmd.tokens;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/dversion.d
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import dmd.dsymbolsem;
import dmd.globals;
import dmd.identifier;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.visitor;

/***********************************************************
Expand Down
1 change: 1 addition & 0 deletions src/dmd/e2ir.d
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import core.stdc.time;

import dmd.root.array;
import dmd.root.ctfloat;
import dmd.root.ctinteger;
import dmd.root.rmem;
import dmd.root.rootobject;
import dmd.root.stringtable;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/expression.d
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ import dmd.objc;
import dmd.opover;
import dmd.optimize;
import dmd.root.ctfloat;
import dmd.root.ctinteger;
import dmd.root.filename;
import dmd.common.outbuffer;
import dmd.root.optional;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/expressionsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import dmd.optimize;
import dmd.parse;
import dmd.printast;
import dmd.root.ctfloat;
import dmd.root.ctinteger;
import dmd.root.file;
import dmd.root.filename;
import dmd.common.outbuffer;
Expand Down
23 changes: 1 addition & 22 deletions src/dmd/globals.d
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@

module dmd.globals;

import core.stdc.stdint;
import dmd.root.array;
import dmd.root.ctinteger;
import dmd.root.filename;
import dmd.common.outbuffer;
import dmd.identifier;
Expand Down Expand Up @@ -473,27 +473,6 @@ extern (C++) struct Global
}
}

// Because int64_t and friends may be any integral type of the
// correct size, we have to explicitly ask for the correct
// integer type to get the correct mangling with dmd

// Be careful not to care about sign when using dinteger_t
// use this instead of integer_t to
// avoid conflicts with system #include's
alias dinteger_t = ulong;
// Signed and unsigned variants
alias sinteger_t = long;
alias uinteger_t = ulong;

alias d_int8 = int8_t;
alias d_uns8 = uint8_t;
alias d_int16 = int16_t;
alias d_uns16 = uint16_t;
alias d_int32 = int32_t;
alias d_uns32 = uint32_t;
alias d_int64 = int64_t;
alias d_uns64 = uint64_t;

version (DMDLIB)
{
version = LocOffset;
Expand Down
34 changes: 1 addition & 33 deletions src/dmd/globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#pragma once

#include "root/dcompat.h"
#include "root/ctinteger.h"
#include "root/ctfloat.h"
#include "common/outbuffer.h"
#include "root/filename.h"
Expand Down Expand Up @@ -321,39 +322,6 @@ struct Global

extern Global global;

// Because int64_t and friends may be any integral type of the correct size,
// we have to explicitly ask for the correct integer type to get the correct
// mangling with dmd. The #if logic here should match the mangling of
// Tint64 and Tuns64 in cppmangle.d.
#if MARS && DMD_VERSION >= 2079 && DMD_VERSION <= 2081 && \
__APPLE__ && __SIZEOF_LONG__ == 8
// DMD versions between 2.079 and 2.081 mapped D long to int64_t on OS X.
typedef uint64_t dinteger_t;
typedef int64_t sinteger_t;
typedef uint64_t uinteger_t;
#elif __SIZEOF_LONG__ == 8
// Be careful not to care about sign when using dinteger_t
// use this instead of integer_t to
// avoid conflicts with system #include's
typedef unsigned long dinteger_t;
// Signed and unsigned variants
typedef long sinteger_t;
typedef unsigned long uinteger_t;
#else
typedef unsigned long long dinteger_t;
typedef long long sinteger_t;
typedef unsigned long long uinteger_t;
#endif

typedef int8_t d_int8;
typedef uint8_t d_uns8;
typedef int16_t d_int16;
typedef uint16_t d_uns16;
typedef int32_t d_int32;
typedef uint32_t d_uns32;
typedef int64_t d_int64;
typedef uint64_t d_uns64;

// file location
struct Loc
{
Expand Down
1 change: 1 addition & 0 deletions src/dmd/hdrgen.d
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import dmd.nspace;
import dmd.parse;
import dmd.root.ctfloat;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.rootobject;
import dmd.root.string;
import dmd.statement;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/iasmdmd.d
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import dmd.tokens;

import dmd.root.ctfloat;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.rmem;
import dmd.root.rootobject;

Expand Down
1 change: 1 addition & 0 deletions src/dmd/initsem.d
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import dmd.importc;
import dmd.init;
import dmd.mtype;
import dmd.opover;
import dmd.root.ctinteger;
import dmd.statement;
import dmd.target;
import dmd.tokens;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/intrange.d
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import dmd.astenums;
import dmd.mtype;
import dmd.expression;
import dmd.globals;
import dmd.root.ctinteger;

private uinteger_t copySign(uinteger_t x, bool sign)
{
Expand Down
1 change: 1 addition & 0 deletions src/dmd/lexer.d
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import dmd.identifier;
import dmd.root.array;
import dmd.root.ctfloat;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.port;
import dmd.root.rmem;
import dmd.root.string;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/mtype.d
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import dmd.init;
import dmd.opover;
import dmd.root.ctfloat;
import dmd.common.outbuffer;
import dmd.root.ctinteger;
import dmd.root.rmem;
import dmd.root.rootobject;
import dmd.root.stringtable;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/optimize.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import dmd.init;
import dmd.mtype;
import dmd.printast;
import dmd.root.ctfloat;
import dmd.root.ctinteger;
import dmd.sideeffect;
import dmd.tokens;
import dmd.visitor;
Expand Down
1 change: 1 addition & 0 deletions src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import dmd.id;
import dmd.identifier;
import dmd.lexer;
import dmd.errors;
import dmd.root.ctinteger;
import dmd.root.filename;
import dmd.common.outbuffer;
import dmd.root.rmem;
Expand Down
38 changes: 38 additions & 0 deletions src/dmd/root/ctinteger.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Compiler implementation of the
* $(LINK2 http://www.dlang.org, D programming language).
*
* Copyright: Copyright (C) 2018 by The D Language Foundation, All Rights Reserved
* Authors: $(LINK2 http://www.digitalmars.com, Walter Bright)
* License: $(LINK2 http://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/src/dmd/root/ctinteger.d, root/_ctinteger.d)
* Documentation: https://dlang.org/phobos/dmd_root_ctinteger.html
* Coverage: https://codecov.io/gh/dlang/dmd/src/master/src/dmd/root/ctinteger.d
*/

module dmd.root.ctinteger;

import core.stdc.stdint;

// Types used by the front-end for compile-time integers

// Because int64_t and friends may be any integral type of the
// correct size, we have to explicitly ask for the correct
// integer type to get the correct mangling with dmd

// Be careful not to care about sign when using dinteger_t
// use this instead of integer_t to
// avoid conflicts with system #include's
alias dinteger_t = ulong;
// Signed and unsigned variants
alias sinteger_t = long;
alias uinteger_t = ulong;

alias d_int8 = int8_t;
alias d_uns8 = uint8_t;
alias d_int16 = int16_t;
alias d_uns16 = uint16_t;
alias d_int32 = int32_t;
alias d_uns32 = uint32_t;
alias d_int64 = int64_t;
alias d_uns64 = uint64_t;
Loading

0 comments on commit b4930f9

Please sign in to comment.