コード例 #1
0
void
InitializeMITSHM(const unsigned char *buf)
{
    TYPE p;

    MITSHMRequest = (unsigned char) (buf[9]);
    MITSHMEvent = (unsigned char) (buf[10]);
    MITSHMError = (unsigned char) (buf[11]);

    DefineEValue(&TD[REQUEST], (unsigned long) MITSHMRequest, "MitshmRequest");
    DefineEValue(&TD[REPLY], (unsigned long) MITSHMRequest, "MitshmReply");
    DefineEValue(&TD[EVENT], (unsigned long) MITSHMEvent, "MitshmEvent");
    DefineEValue(&TD[ERROR], (unsigned long) MITSHMError, "MitshmError");

    p = DefineType(MITSHMREQUEST, ENUMERATED, "MITSHMREQUEST",
                   (PrintProcType) PrintENUMERATED);
    DefineEValue(p, 0L, "MitshmQueryVersion");
    DefineEValue(p, 1L, "MitshmAttach");
    DefineEValue(p, 2L, "MitshmDetach");
    DefineEValue(p, 3L, "MitshmPutImage");
    DefineEValue(p, 4L, "MitshmGetImage");
    DefineEValue(p, 5L, "MitshmCreatePixmap");

    p = DefineType(MITSHMREPLY, ENUMERATED, "MITSHMREPLY",
                   (PrintProcType) PrintENUMERATED);
    DefineEValue(p, 0L, "QueryVersion");
    DefineEValue(p, 4L, "GetImage");

    p = DefineType(MITSHMEVENT, ENUMERATED, "MITSHMEVENT",
                   (PrintProcType) PrintENUMERATED);
    DefineEValue(p, 0L, "CompletionEvent");

    InitializeExtensionDecoder(MITSHMRequest, mitshm_decode_req,
                               mitshm_decode_reply);
    InitializeExtensionErrorDecoder(MITSHMError, mitshm_decode_error);
    InitializeExtensionEventDecoder(MITSHMEvent, mitshm_decode_event);
}
コード例 #2
0
ファイル: ObjIeeeAsciiRead.cpp プロジェクト: jossk/OrangeC
bool ObjIeeeAscii::TypeSpec(const char *buffer, eParseType ParseType)
{
    if (!file)
        ThrowSyntax(buffer, ParseType);
    int pos = 2;
    char ch = buffer[pos++];
    int index = ObjUtil::FromHex(buffer, &pos);
    if (buffer[pos++] != ',')
        ThrowSyntax(buffer, ParseType);
    switch (ch)
    {
        case 'A':
        case 'E':
        case 'X':
        case 'N':
        case 'I':
        {
            ObjSymbol *symbol = FindSymbol(ch, index);
            if (!symbol)
                ThrowSyntax(buffer, ParseType);
            if (buffer[pos++] != 'T')
                ThrowSyntax(buffer, ParseType);
            index = ObjUtil::FromHex(buffer, &pos);
            CheckTerm(buffer + pos);
            ObjType *type;
            /* won't get a 'special' type deriving type here */
            if (index < ObjType::eReservedTop)
                type = factory->MakeType((ObjType::eType)index);
            else
                type = GetType(index);
            if (!type)
                ThrowSyntax(buffer, ParseType);
            symbol->SetBaseType(type);	
            break;
        }
        case 'T':
        {
            DefineType(index, buffer, &pos);
            CheckTerm(buffer + pos);
            break;
        }
        default:
            ThrowSyntax(buffer, ParseType);
            break;
    }
    return false;
}
コード例 #3
0
static void InitializePredefinedMacros(const TargetInfo &TI,
                                       const LangOptions &LangOpts,
                                       std::vector<char> &Buf) {
    char MacroBuf[60];
    // Compiler version introspection macros.
    DefineBuiltinMacro(Buf, "__llvm__=1");   // LLVM Backend
    DefineBuiltinMacro(Buf, "__clang__=1");  // Clang Frontend

    // Currently claim to be compatible with GCC 4.2.1-5621.
    DefineBuiltinMacro(Buf, "__GNUC_MINOR__=2");
    DefineBuiltinMacro(Buf, "__GNUC_PATCHLEVEL__=1");
    DefineBuiltinMacro(Buf, "__GNUC__=4");
    DefineBuiltinMacro(Buf, "__GXX_ABI_VERSION=1002");
    DefineBuiltinMacro(Buf, "__VERSION__=\"4.2.1 Compatible Clang Compiler\"");


    // Initialize language-specific preprocessor defines.

    // These should all be defined in the preprocessor according to the
    // current language configuration.
    if (!LangOpts.Microsoft)
        DefineBuiltinMacro(Buf, "__STDC__=1");
    if (LangOpts.AsmPreprocessor)
        DefineBuiltinMacro(Buf, "__ASSEMBLER__=1");

    if (!LangOpts.CPlusPlus) {
        if (LangOpts.C99)
            DefineBuiltinMacro(Buf, "__STDC_VERSION__=199901L");
        else if (!LangOpts.GNUMode && LangOpts.Digraphs)
            DefineBuiltinMacro(Buf, "__STDC_VERSION__=199409L");
    }

    // Standard conforming mode?
    if (!LangOpts.GNUMode)
        DefineBuiltinMacro(Buf, "__STRICT_ANSI__=1");

    if (LangOpts.CPlusPlus0x)
        DefineBuiltinMacro(Buf, "__GXX_EXPERIMENTAL_CXX0X__");

    if (LangOpts.Freestanding)
        DefineBuiltinMacro(Buf, "__STDC_HOSTED__=0");
    else
        DefineBuiltinMacro(Buf, "__STDC_HOSTED__=1");

    if (LangOpts.ObjC1) {
        DefineBuiltinMacro(Buf, "__OBJC__=1");
        if (LangOpts.ObjCNonFragileABI) {
            DefineBuiltinMacro(Buf, "__OBJC2__=1");
            DefineBuiltinMacro(Buf, "OBJC_ZEROCOST_EXCEPTIONS=1");
            DefineBuiltinMacro(Buf, "__EXCEPTIONS=1");
        }

        if (LangOpts.getGCMode() != LangOptions::NonGC)
            DefineBuiltinMacro(Buf, "__OBJC_GC__=1");

        if (LangOpts.NeXTRuntime)
            DefineBuiltinMacro(Buf, "__NEXT_RUNTIME__=1");
    }

    // darwin_constant_cfstrings controls this. This is also dependent
    // on other things like the runtime I believe.  This is set even for C code.
    DefineBuiltinMacro(Buf, "__CONSTANT_CFSTRINGS__=1");

    if (LangOpts.ObjC2)
        DefineBuiltinMacro(Buf, "OBJC_NEW_PROPERTIES");

    if (LangOpts.ObjCSenderDispatch)
        DefineBuiltinMacro(Buf, "__OBJC_SENDER_AWARE_DISPATCH__");

    if (LangOpts.PascalStrings)
        DefineBuiltinMacro(Buf, "__PASCAL_STRINGS__");

    if (LangOpts.Blocks) {
        DefineBuiltinMacro(Buf, "__block=__attribute__((__blocks__(byref)))");
        DefineBuiltinMacro(Buf, "__BLOCKS__=1");
    }

    if (LangOpts.CPlusPlus) {
        DefineBuiltinMacro(Buf, "__DEPRECATED=1");
        DefineBuiltinMacro(Buf, "__EXCEPTIONS=1");
        DefineBuiltinMacro(Buf, "__GNUG__=4");
        DefineBuiltinMacro(Buf, "__GXX_WEAK__=1");
        if (LangOpts.GNUMode)
            DefineBuiltinMacro(Buf, "__cplusplus=1");
        else
            // C++ [cpp.predefined]p1:
            //   The name_ _cplusplusis defined to the value199711Lwhen compiling a
            //   C++ translation unit.
            DefineBuiltinMacro(Buf, "__cplusplus=199711L");
        DefineBuiltinMacro(Buf, "__private_extern__=extern");
    }

    // Filter out some microsoft extensions when trying to parse in ms-compat
    // mode.
    if (LangOpts.Microsoft) {
        DefineBuiltinMacro(Buf, "__int8=__INT8_TYPE__");
        DefineBuiltinMacro(Buf, "__int16=__INT16_TYPE__");
        DefineBuiltinMacro(Buf, "__int32=__INT32_TYPE__");
        DefineBuiltinMacro(Buf, "__int64=__INT64_TYPE__");
    }

    if (LangOpts.Optimize)
        DefineBuiltinMacro(Buf, "__OPTIMIZE__=1");
    if (LangOpts.OptimizeSize)
        DefineBuiltinMacro(Buf, "__OPTIMIZE_SIZE__=1");

    // Initialize target-specific preprocessor defines.

    // Define type sizing macros based on the target properties.
    assert(TI.getCharWidth() == 8 && "Only support 8-bit char so far");
    DefineBuiltinMacro(Buf, "__CHAR_BIT__=8");

    unsigned IntMaxWidth;
    const char *IntMaxSuffix;
    if (TI.getIntMaxType() == TargetInfo::SignedLongLong) {
        IntMaxWidth = TI.getLongLongWidth();
        IntMaxSuffix = "LL";
    } else if (TI.getIntMaxType() == TargetInfo::SignedLong) {
        IntMaxWidth = TI.getLongWidth();
        IntMaxSuffix = "L";
    } else {
        assert(TI.getIntMaxType() == TargetInfo::SignedInt);
        IntMaxWidth = TI.getIntWidth();
        IntMaxSuffix = "";
    }

    DefineTypeSize("__SCHAR_MAX__", TI.getCharWidth(), "", true, Buf);
    DefineTypeSize("__SHRT_MAX__", TI.getShortWidth(), "", true, Buf);
    DefineTypeSize("__INT_MAX__", TI.getIntWidth(), "", true, Buf);
    DefineTypeSize("__LONG_MAX__", TI.getLongWidth(), "L", true, Buf);
    DefineTypeSize("__LONG_LONG_MAX__", TI.getLongLongWidth(), "LL", true, Buf);
    DefineTypeSize("__WCHAR_MAX__", TI.getWCharWidth(), "", true, Buf);
    DefineTypeSize("__INTMAX_MAX__", IntMaxWidth, IntMaxSuffix, true, Buf);

    DefineType("__INTMAX_TYPE__", TI.getIntMaxType(), Buf);
    DefineType("__UINTMAX_TYPE__", TI.getUIntMaxType(), Buf);
    DefineType("__PTRDIFF_TYPE__", TI.getPtrDiffType(0), Buf);
    DefineType("__INTPTR_TYPE__", TI.getIntPtrType(), Buf);
    DefineType("__SIZE_TYPE__", TI.getSizeType(), Buf);
    DefineType("__WCHAR_TYPE__", TI.getWCharType(), Buf);
    // FIXME: TargetInfo hookize __WINT_TYPE__.
    DefineBuiltinMacro(Buf, "__WINT_TYPE__=int");

    DefineFloatMacros(Buf, "FLT", &TI.getFloatFormat());
    DefineFloatMacros(Buf, "DBL", &TI.getDoubleFormat());
    DefineFloatMacros(Buf, "LDBL", &TI.getLongDoubleFormat());

    // Define a __POINTER_WIDTH__ macro for stdint.h.
    sprintf(MacroBuf, "__POINTER_WIDTH__=%d", (int)TI.getPointerWidth(0));
    DefineBuiltinMacro(Buf, MacroBuf);

    if (!LangOpts.CharIsSigned)
        DefineBuiltinMacro(Buf, "__CHAR_UNSIGNED__");

    // Define fixed-sized integer types for stdint.h
    assert(TI.getCharWidth() == 8 && "unsupported target types");
    assert(TI.getShortWidth() == 16 && "unsupported target types");
    DefineBuiltinMacro(Buf, "__INT8_TYPE__=char");
    DefineBuiltinMacro(Buf, "__INT16_TYPE__=short");

    if (TI.getIntWidth() == 32)
        DefineBuiltinMacro(Buf, "__INT32_TYPE__=int");
    else {
        assert(TI.getLongLongWidth() == 32 && "unsupported target types");
        DefineBuiltinMacro(Buf, "__INT32_TYPE__=long long");
    }

    // 16-bit targets doesn't necessarily have a 64-bit type.
    if (TI.getLongLongWidth() == 64)
        DefineType("__INT64_TYPE__", TI.getInt64Type(), Buf);

    // Add __builtin_va_list typedef.
    {
        const char *VAList = TI.getVAListDeclaration();
        Buf.insert(Buf.end(), VAList, VAList+strlen(VAList));
        Buf.push_back('\n');
    }

    if (const char *Prefix = TI.getUserLabelPrefix()) {
        sprintf(MacroBuf, "__USER_LABEL_PREFIX__=%s", Prefix);
        DefineBuiltinMacro(Buf, MacroBuf);
    }

    // Build configuration options.  FIXME: these should be controlled by
    // command line options or something.
    DefineBuiltinMacro(Buf, "__FINITE_MATH_ONLY__=0");

    if (LangOpts.GNUInline)
        DefineBuiltinMacro(Buf, "__GNUC_GNU_INLINE__=1");
    else
        DefineBuiltinMacro(Buf, "__GNUC_STDC_INLINE__=1");

    if (LangOpts.NoInline)
        DefineBuiltinMacro(Buf, "__NO_INLINE__=1");

    if (unsigned PICLevel = LangOpts.PICLevel) {
        sprintf(MacroBuf, "__PIC__=%d", PICLevel);
        DefineBuiltinMacro(Buf, MacroBuf);

        sprintf(MacroBuf, "__pic__=%d", PICLevel);
        DefineBuiltinMacro(Buf, MacroBuf);
    }

    // Macros to control C99 numerics and <float.h>
    DefineBuiltinMacro(Buf, "__FLT_EVAL_METHOD__=0");
    DefineBuiltinMacro(Buf, "__FLT_RADIX__=2");
    sprintf(MacroBuf, "__DECIMAL_DIG__=%d",
            PickFP(&TI.getLongDoubleFormat(), -1/*FIXME*/, 17, 21, 33, 36));
    DefineBuiltinMacro(Buf, MacroBuf);

    if (LangOpts.getStackProtectorMode() == LangOptions::SSPOn)
        DefineBuiltinMacro(Buf, "__SSP__=1");
    else if (LangOpts.getStackProtectorMode() == LangOptions::SSPReq)
        DefineBuiltinMacro(Buf, "__SSP_ALL__=2");

    // Get other target #defines.
    TI.getTargetDefines(LangOpts, Buf);
}