/usr/include/falcon/common.h is in falconpl-dev 0.9.6.9-git20120606-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 | /*
FALCON - The Falcon Programming Language.
FILE: flc_common.h
Definition for falcon common library.
-------------------------------------------------------------------
Author: Giancarlo Niccolai
Begin: dom giu 20 2004
-------------------------------------------------------------------
(C) Copyright 2004: the FALCON developers (see list in AUTHORS file)
See LICENSE file for licensing details.
*/
#ifndef flc_COMMON_H
#define flc_COMMON_H
#include <falcon/types.h>
namespace Falcon
{
class String;
#define flc_CURRENT_VER 1
#define flc_CURRENT_SUB 0
#define flcC_SYM_VAR 0
#define flcC_SYM_FUNC 1
#define flcC_SYM_EXT 2
#define flcC_SYM_CLASS 3
#define flcC_SYM_VARPROP 4
#define flcC_EXPORT_BIT 0x80
#define flcC_VAL_NIL 0
#define flcC_VAL_INT 1
#define flcC_VAL_NUM 2
#define flcC_VAL_STRID 3
#define flcC_VAL_SIMID 4
/** Seed for the hash key checksum generator */
#define flc_HASH_SEED 0xC2AF3DE4
/** Utility class to char pointers.
This class is just an operator that compares the strings pointed by its parameters.
It is used in some maps that have a string pointer as they key, as it points a string
being the name of a symbol or other kind of string whose instance must be kept somewhere
else.
*/
class CharPtrCmp
{
public:
bool operator() ( const char *s1, const char *s2 ) const
{
while( *s1 && *s2 && *s1 == *s2 ) {
s1 ++;
s2 ++;
}
return (*s1 < *s2);
}
};
#define flc_ASM_GLOBAL 0
#define flc_ASM_LOCAL 1
#define flc_ASM_PARAM 2
#if FALCON_LITTLE_ENDIAN == 1
inline uint64 grabInt64( void* data ) { return *(uint64*)data; }
inline int64 loadInt64( void* data ) { return *(int64*)data; }
inline numeric grabNum( void* data ) { return *(numeric*)data; }
inline numeric loadNum( void* data ) { return *(numeric*)data; }
inline uint64 endianInt64( const uint64 param ) { return param; }
inline uint32 endianInt32( const uint32 param ) { return param; }
inline uint16 endianInt16( const uint16 param ) { return param; }
inline numeric endianNum( const numeric param ) { return param; }
#else
inline uint64 endianInt64( const uint64 param ) {
byte *chars = (byte *) ¶m;
return ((uint64)chars[7]) << 56 | ((uint64)chars[6]) << 48 | ((uint64)chars[5]) << 40 |
((uint64)chars[4]) << 32 | ((uint64)chars[3]) << 24 | ((uint64)chars[2]) << 16 |
((uint64)chars[1]) << 8 | ((uint64)chars[0]);
}
inline uint64 grabInt64( void* data ) {
byte *chars = (byte *) data;
return ((uint64)chars[7]) << 56 | ((uint64)chars[6]) << 48 | ((uint64)chars[5]) << 40 |
((uint64)chars[4]) << 32 | ((uint64)chars[3]) << 24 | ((uint64)chars[2]) << 16 |
((uint64)chars[1]) << 8 | ((uint64)chars[0]);
}
inline numeric grabNum( void* numMemory )
{
const byte* data = (const byte*) numMemory;
union t_unumeric {
byte buffer[ sizeof(numeric) ];
numeric number;
} unumeric;
uint32 i;
for ( i = 0; i < sizeof( numeric ); i++ ) {
unumeric.buffer[i] = data[(sizeof( numeric )-1) - i];
}
return unumeric.number;
}
inline numeric endianNum( const numeric ¶m )
{
return grabNum( (void*) ¶m );
}
inline numeric loadNum( void* data )
{
byte* bdata = (byte*) data;
union t_unumeric {
struct t_integer {
uint32 high;
uint32 low;
} integer;
numeric number;
} unumeric;
unumeric.integer.high = *reinterpret_cast<uint32*>(bdata);
unumeric.integer.low = *reinterpret_cast<uint32*>(bdata+sizeof(uint32));
return unumeric.number;
}
inline int64 loadInt64( void* data )
{
byte* bdata = (byte*) data;
uint64 res = *reinterpret_cast<uint32*>(bdata);
res <<= 32;
res |= *reinterpret_cast<uint32*>(bdata+sizeof(uint32));
return (int64) res;
}
inline uint32 endianInt32( const uint32 param ) {
byte *chars = (byte *) ¶m;
return ((uint32)chars[3]) << 24 | ((uint32)chars[2]) << 16 | ((uint32)chars[1]) << 8 | ((uint32)chars[0]);
}
inline uint16 endianInt16( const uint16 param ) {
byte *chars = (byte *) ¶m;
return ((uint32)chars[1]) << 8 | ((uint32)chars[0]);
}
#endif /* FALCON_LITTLE_ENDIAN */
inline int charToHex( const char elem )
{
if( elem >= '0' && elem <= '9' )
return elem - '0';
else if( elem >= 'A' && elem <= 'F' )
return elem - 'A';
else if( elem >= 'a' && elem <= 'f' )
return elem - 'a';
return -1;
}
FALCON_DYN_SYM uint32 calcMemHash( const char *memory, uint32 size );
FALCON_DYN_SYM uint32 calcCstrHash( const char *cstring );
FALCON_DYN_SYM uint32 calcStringHash( const String &string );
inline uint32 calcIntHash( const int32 number ) { return flc_HASH_SEED * number; }
}
#endif
/* end of flc_common.h */
|