1: // Copyright (C) 1996-1998 by Symantec
  2: // Copyright (C) 2000-2010 by Digital Mars
  3: // All Rights Reserved
  4: // http://www.digitalmars.com
  5: // Written by Walter Bright
  6: /*
  7:  * This source file is made available for personal use
  8:  * only. The license is in /dmd/src/dmd/backendlicense.txt
  9:  * or /dm/src/dmd/backendlicense.txt
 10:  * For any other uses, please contact Digital Mars.
 11:  */
 12: 
 13: #if !SPP
 14: 
 15: #include        <stdio.h>
 16: #include        <string.h>
 17: #include        <time.h>
 18: #include        "cc.h"
 19: #include        "type.h"
 20: #include        "oper.h"
 21: #include        "global.h"
 22: #include        "code.h"
 23: 
 24: static char __file__[] = __FILE__;      /* for tassert.h                */
 25: #include        "tassert.h"
 26: 
 27: Symbol *rtlsym[RTLSYM_MAX];
 28: 
 29: #if MARS
 30: // This varies depending on C ABI
 31: #define FREGSAVED       fregsaved
 32: #else
 33: #define FREGSAVED       (mBP | mBX | mSI | mDI)
 34: #endif
 35: 
 36: static Symbol rtlsym2[RTLSYM_MAX];
 37: 
 38: /******************************************
 39:  * Initialize rtl symbols.
 40:  */
 41: 
 42: void rtlsym_init()
 43: {
 44:     static int inited;
 45: 
 46:     if (!inited)
 47:     {   inited++;
 48: 
 49:         //printf("rtlsym_init(%s)\n", regm_str(FREGSAVED));
 50: 
 51:         for (int i = 0; i < RTLSYM_MAX; i++)
 52:         {
 53:             rtlsym[i] = &rtlsym2[i];
 54: #ifdef DEBUG
 55:             rtlsym[i]->id = IDsymbol;
 56: #endif
 57:             rtlsym[i]->Stype = tsclib;
 58:             rtlsym[i]->Ssymnum = -1;
 59:             rtlsym[i]->Sclass = SCextern;
 60:             rtlsym[i]->Sfl = FLfunc;
 61: #if ELFOBJ || MACHOBJ
 62:             rtlsym[i]->obj_si = (unsigned)-1;
 63:             rtlsym[i]->dwarf_off = (unsigned)-1;
 64: #endif
 65:             rtlsym[i]->Sregsaved = FREGSAVED;
 66:         }
 67: 
 68: #if MARS
 69:         type *t = type_fake(LARGECODE ? TYffunc : TYnfunc);
 70:         t->Tmangle = mTYman_c;
 71:         t->Tcount++;
 72: 
 73:         // Variadic function
 74:         type *tv = type_fake(LARGECODE ? TYffunc : TYnfunc);
 75:         tv->Tmangle = mTYman_c;
 76:         tv->Tcount++;
 77: #endif
 78: 
 79: #if MACHOBJ
 80:         type *tw = type_fake(TYnpfunc);
 81:         tw->Tmangle = mTYman_sys;
 82:         tw->Tcount++;
 83: #else
 84:         type *tw = NULL;
 85: #endif
 86: 
 87: #undef SYMBOL_Z
 88: #define SYMBOL_Z(e, fl, saved, n, flags, ty)                            \
 89:         if (ty) rtlsym[RTLSYM_##e]->Stype = ty;                         \
 90:         if (fl != FLfunc) rtlsym[RTLSYM_##e]->Sfl = fl;                 \
 91:         if (flags) rtlsym[RTLSYM_##e]->Sflags = flags;                  \
 92:         if (saved != FREGSAVED) rtlsym[RTLSYM_##e]->Sregsaved = saved;  \
 93:         strcpy(rtlsym[RTLSYM_##e]->Sident, n);                          \
 94: 
 95:         RTLSYMS
warning C4996: 'strcpy': This function or variable may be unsafe. Consider using strcpy_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details. c:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\string.h(105) : see declaration of 'strcpy'
warning C4806: '|' : unsafe operation: no value of type 'bool' promoted to type 'int' can equal the given constant
warning C4554: '|' : check operator precedence for possible error; use parentheses to clarify precedence
warning C4806: '|' : unsafe operation: no value of type 'bool' promoted to type 'int' can equal the given constant
warning C4554: '|' : check operator precedence for possible error; use parentheses to clarify precedence
warning C4806: '|' : unsafe operation: no value of type 'bool' promoted to type 'int' can equal the given constant
warning C4554: '|' : check operator precedence for possible error; use parentheses to clarify precedence
warning C4806: '|' : unsafe operation: no value of type 'bool' promoted to type 'int' can equal the given constant
warning C4554: '|' : check operator precedence for possible error; use parentheses to clarify precedence
warning C4806: '|' : unsafe operation: no value of type 'bool' promoted to type 'int' can equal the given constant
warning C4554: '|' : check operator precedence for possible error; use parentheses to clarify precedence
warning C6316: Incorrect operator: tested expression is constant and non-zero. Use bitwise-and to determine whether bits are set
warning C6281: Incorrect order of operations: relational operators have higher precedence than bitwise operators
warning C6316: Incorrect operator: tested expression is constant and non-zero. Use bitwise-and to determine whether bits are set
warning C6281: Incorrect order of operations: relational operators have higher precedence than bitwise operators
warning C6316: Incorrect operator: tested expression is constant and non-zero. Use bitwise-and to determine whether bits are set
warning C6281: Incorrect order of operations: relational operators have higher precedence than bitwise operators
warning C6316: Incorrect operator: tested expression is constant and non-zero. Use bitwise-and to determine whether bits are set
warning C6281: Incorrect order of operations: relational operators have higher precedence than bitwise operators
warning C6316: Incorrect operator: tested expression is constant and non-zero. Use bitwise-and to determine whether bits are set
warning C6281: Incorrect order of operations: relational operators have higher precedence than bitwise operators
96: } 97: } 98: 99: /******************************* 100: * Reset the symbols for the case when we are generating multiple 101: * .OBJ files from one compile. 102: */ 103: 104: #if MARS 105: 106: void rtlsym_reset() 107: { int i; 108: 109: clib_inited = 0; 110: for (i = 0; i < RTLSYM_MAX; i++) 111: { rtlsym[i]->Sxtrnnum = 0; 112: rtlsym[i]->Stypidx = 0; 113: } 114: } 115: 116: #endif 117: 118: /******************************* 119: */ 120: 121: void rtlsym_term() 122: { 123: } 124: 125: #endif 126: