~ubuntu-branches/ubuntu/trusty/luajit/trusty

« back to all changes in this revision

Viewing changes to src/lj_def.h

  • Committer: Package Import Robot
  • Author(s): Enrico Tassi
  • Date: 2013-05-20 18:08:12 UTC
  • mfrom: (1.2.2)
  • Revision ID: package-import@ubuntu.com-20130520180812-h514ggtgxg3nqmxl
Tags: 2.0.1+hotfix1+dfsg-1
* New upsream release
* Packaging moved to git

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
** LuaJIT common internal definitions.
3
 
** Copyright (C) 2005-2012 Mike Pall. See Copyright Notice in luajit.h
 
3
** Copyright (C) 2005-2013 Mike Pall. See Copyright Notice in luajit.h
4
4
*/
5
5
 
6
6
#ifndef _LJ_DEF_H
120
120
#define LJ_NOINLINE     __attribute__((noinline))
121
121
 
122
122
#if defined(__ELF__) || defined(__MACH__)
123
 
#if !((defined(__sun__) && defined(__svr4__)) || defined(__solaris__) || defined(__CELLOS_LV2__))
 
123
#if !((defined(__sun__) && defined(__svr4__)) || defined(__CELLOS_LV2__))
124
124
#define LJ_NOAPI        extern __attribute__((visibility("hidden")))
125
125
#endif
126
126
#endif
242
242
#define LJ_FASTCALL     __fastcall
243
243
#endif
244
244
 
 
245
#ifdef _M_PPC
 
246
unsigned int _CountLeadingZeros(long);
 
247
#pragma intrinsic(_CountLeadingZeros)
 
248
static LJ_AINLINE uint32_t lj_fls(uint32_t x)
 
249
{
 
250
  return _CountLeadingZeros(x) ^ 31;
 
251
}
 
252
#else
245
253
unsigned char _BitScanForward(uint32_t *, unsigned long);
246
254
unsigned char _BitScanReverse(uint32_t *, unsigned long);
247
 
unsigned long _byteswap_ulong(unsigned long);
248
 
uint64_t _byteswap_uint64(uint64_t);
 
255
#pragma intrinsic(_BitScanForward)
 
256
#pragma intrinsic(_BitScanReverse)
249
257
 
250
258
static LJ_AINLINE uint32_t lj_ffs(uint32_t x)
251
259
{
256
264
{
257
265
  uint32_t r; _BitScanReverse(&r, x); return r;
258
266
}
 
267
#endif
259
268
 
 
269
unsigned long _byteswap_ulong(unsigned long);
 
270
uint64_t _byteswap_uint64(uint64_t);
260
271
#define lj_bswap(x)     (_byteswap_ulong((x)))
261
272
#define lj_bswap64(x)   (_byteswap_uint64((x)))
262
273
 
263
 
/* MSVC is only supported on x86/x64, where unaligned loads are always ok. */
 
274
#if defined(_M_PPC) && defined(LUAJIT_NO_UNALIGNED)
 
275
/*
 
276
** Replacement for unaligned loads on Xbox 360. Disabled by default since it's
 
277
** usually more costly than the occasional stall when crossing a cache-line.
 
278
*/
 
279
static LJ_AINLINE uint16_t lj_getu16(const void *v)
 
280
{
 
281
  const uint8_t *p = (const uint8_t *)v;
 
282
  return (uint16_t)((p[0]<<8) | p[1]);
 
283
}
 
284
static LJ_AINLINE uint32_t lj_getu32(const void *v)
 
285
{
 
286
  const uint8_t *p = (const uint8_t *)v;
 
287
  return (uint32_t)((p[0]<<24) | (p[1]<<16) | (p[2]<<8) | p[3]);
 
288
}
 
289
#else
 
290
/* Unaligned loads are generally ok on x86/x64. */
264
291
#define lj_getu16(p)    (*(uint16_t *)(p))
265
292
#define lj_getu32(p)    (*(uint32_t *)(p))
 
293
#endif
266
294
 
267
295
#else
268
296
#error "missing defines for your compiler"