sourcepawn/compiler/amx.h
changeset 27 764c6dd3dc25
child 29 e0b15a294a0d
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sourcepawn/compiler/amx.h	Sat Jul 15 05:15:15 2006 +0000
     1.3 @@ -0,0 +1,629 @@
     1.4 +/*  Pawn Abstract Machine (for the Pawn language)
     1.5 + *
     1.6 + *  Copyright (c) ITB CompuPhase, 1997-2006
     1.7 + *
     1.8 + *  This software is provided "as-is", without any express or implied warranty.
     1.9 + *  In no event will the authors be held liable for any damages arising from
    1.10 + *  the use of this software.
    1.11 + *
    1.12 + *  Permission is granted to anyone to use this software for any purpose,
    1.13 + *  including commercial applications, and to alter it and redistribute it
    1.14 + *  freely, subject to the following restrictions:
    1.15 + *
    1.16 + *  1.  The origin of this software must not be misrepresented; you must not
    1.17 + *      claim that you wrote the original software. If you use this software in
    1.18 + *      a product, an acknowledgment in the product documentation would be
    1.19 + *      appreciated but is not required.
    1.20 + *  2.  Altered source versions must be plainly marked as such, and must not be
    1.21 + *      misrepresented as being the original software.
    1.22 + *  3.  This notice may not be removed or altered from any source distribution.
    1.23 + *
    1.24 + *  Version: $Id: amx.h 3579 2006-06-06 13:35:29Z thiadmer $
    1.25 + */
    1.26 +
    1.27 +#ifndef AMX_H_INCLUDED
    1.28 +#define AMX_H_INCLUDED
    1.29 +
    1.30 +#include <stdlib.h>   /* for size_t */
    1.31 +#include <limits.h>
    1.32 +
    1.33 +#if defined FREEBSD && !defined __FreeBSD__
    1.34 +  #define __FreeBSD__
    1.35 +#endif
    1.36 +#if defined LINUX || defined __FreeBSD__ || defined __OpenBSD__
    1.37 +  #include <sclinux.h>
    1.38 +#endif
    1.39 +
    1.40 +#if defined __GNUC__
    1.41 +  #include <stdint.h>
    1.42 +  #define HAVE_STDINT_H
    1.43 +#elif !defined HAVE_STDINT_H
    1.44 +  #if defined __LCC__ || defined __DMC__ || defined LINUX || (defined __WATCOMC__ && __WATCOMC__ >= 1200)
    1.45 +    #if defined HAVE_INTTYPES_H
    1.46 +      #include <inttypes.h>
    1.47 +    #else
    1.48 +      #include <stdint.h>
    1.49 +    #endif
    1.50 +  #elif !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L
    1.51 +    /* The ISO C99 defines the int16_t and int_32t types. If the compiler got
    1.52 +     * here, these types are probably undefined.
    1.53 +     */
    1.54 +    #if defined __MACH__
    1.55 +      #include <ppc/types.h>
    1.56 +      typedef unsigned short int  uint16_t;
    1.57 +      typedef unsigned long int   uint32_t;
    1.58 +    #elif defined __FreeBSD__
    1.59 +      #include <inttypes.h>
    1.60 +    #else
    1.61 +      typedef short int           int16_t;
    1.62 +      typedef unsigned short int  uint16_t;
    1.63 +      #if defined SN_TARGET_PS2
    1.64 +        typedef int               int32_t;
    1.65 +        typedef unsigned int      uint32_t;
    1.66 +      #else
    1.67 +        typedef long int          int32_t;
    1.68 +        typedef unsigned long int uint32_t;
    1.69 +      #endif
    1.70 +      #if defined __WIN32__ || defined _WIN32 || defined WIN32
    1.71 +        typedef __int64	          int64_t;
    1.72 +        typedef unsigned __int64  uint64_t;
    1.73 +        #define HAVE_I64
    1.74 +      #elif defined __GNUC__
    1.75 +        typedef long long         int64_t;
    1.76 +        typedef unsigned long long uint64_t;
    1.77 +        #define HAVE_I64
    1.78 +      #endif
    1.79 +    #endif
    1.80 +  #endif
    1.81 +  #define HAVE_STDINT_H
    1.82 +#endif
    1.83 +#if defined _LP64 || defined WIN64 || defined _WIN64
    1.84 +  #if !defined __64BIT__
    1.85 +    #define __64BIT__
    1.86 +  #endif
    1.87 +#endif
    1.88 +
    1.89 +#if HAVE_ALLOCA_H
    1.90 +  #include <alloca.h>
    1.91 +#endif
    1.92 +#if defined __WIN32__ || defined _WIN32 || defined WIN32 /* || defined __MSDOS__ */
    1.93 +  #if !defined alloca
    1.94 +    #define alloca(n)   _alloca(n)
    1.95 +  #endif
    1.96 +#endif
    1.97 +
    1.98 +#if !defined arraysize
    1.99 +  #define arraysize(array)  (sizeof(array) / sizeof((array)[0]))
   1.100 +#endif
   1.101 +#if !defined assert_static
   1.102 +  /* see "Compile-Time Assertions" by Ralf Holly,
   1.103 +   * C/C++ Users Journal, November 2004
   1.104 +   */
   1.105 +  #define assert_static(e) \
   1.106 +    do { \
   1.107 +      enum { assert_static__ = 1/(e) }; \
   1.108 +    } while (0)
   1.109 +#endif
   1.110 +
   1.111 +#ifdef  __cplusplus
   1.112 +extern  "C" {
   1.113 +#endif
   1.114 +
   1.115 +#if defined PAWN_DLL
   1.116 +  #if !defined AMX_NATIVE_CALL
   1.117 +    #define AMX_NATIVE_CALL __stdcall
   1.118 +  #endif
   1.119 +  #if !defined AMXAPI
   1.120 +    #define AMXAPI          __stdcall
   1.121 +  #endif
   1.122 +#endif
   1.123 +
   1.124 +/* calling convention for native functions */
   1.125 +#if !defined AMX_NATIVE_CALL
   1.126 +  #define AMX_NATIVE_CALL
   1.127 +#endif
   1.128 +/* calling convention for all interface functions and callback functions */
   1.129 +#if !defined AMXAPI
   1.130 +  #if defined STDECL
   1.131 +    #define AMXAPI      __stdcall
   1.132 +  #elif defined CDECL
   1.133 +    #define AMXAPI      __cdecl
   1.134 +  #elif defined GCC_HASCLASSVISIBILITY
   1.135 +    #define AMXAPI __attribute__ ((visibility("default")))
   1.136 +  #else
   1.137 +    #define AMXAPI
   1.138 +  #endif
   1.139 +#endif
   1.140 +#if !defined AMXEXPORT
   1.141 +  #define AMXEXPORT
   1.142 +#endif
   1.143 +
   1.144 +/* File format version (in CUR_FILE_VERSION)
   1.145 + *   0 (original version)
   1.146 + *   1 (opcodes JUMP.pri, SWITCH and CASETBL)
   1.147 + *   2 (compressed files)
   1.148 + *   3 (public variables)
   1.149 + *   4 (opcodes SWAP.pri/alt and PUSHADDR)
   1.150 + *   5 (tagnames table)
   1.151 + *   6 (reformatted header)
   1.152 + *   7 (name table, opcodes SYMTAG & SYSREQ.D)
   1.153 + *   8 (opcode STMT, renewed debug interface)
   1.154 + *   9 (macro opcodes)
   1.155 + * MIN_FILE_VERSION is the lowest file version number that the current AMX
   1.156 + * implementation supports. If the AMX file header gets new fields, this number
   1.157 + * often needs to be incremented. MAX_AMX_VERSION is the lowest AMX version that
   1.158 + * is needed to support the current file version. When there are new opcodes,
   1.159 + * this number needs to be incremented.
   1.160 + * The file version supported by the JIT may run behind MIN_AMX_VERSION. So
   1.161 + * there is an extra constant for it: MAX_FILE_VER_JIT.
   1.162 + */
   1.163 +#define CUR_FILE_VERSION  9     /* current file version; also the current AMX version */
   1.164 +#define MIN_FILE_VERSION  6     /* lowest supported file format version for the current AMX version */
   1.165 +#define MIN_AMX_VERSION   9     /* minimum AMX version needed to support the current file format */
   1.166 +#define MAX_FILE_VER_JIT  8     /* file version supported by the JIT */
   1.167 +#define MIN_AMX_VER_JIT   8     /* AMX version supported by the JIT */
   1.168 +
   1.169 +#if !defined PAWN_CELL_SIZE
   1.170 +  #define PAWN_CELL_SIZE 32     /* by default, use 32-bit cells */
   1.171 +#endif
   1.172 +#if PAWN_CELL_SIZE==16
   1.173 +  typedef uint16_t  ucell;
   1.174 +  typedef int16_t   cell;
   1.175 +#elif PAWN_CELL_SIZE==32
   1.176 +  typedef uint32_t  ucell;
   1.177 +  typedef int32_t   cell;
   1.178 +#elif PAWN_CELL_SIZE==64
   1.179 +  typedef uint64_t  ucell;
   1.180 +  typedef int64_t   cell;
   1.181 +#else
   1.182 +  #error Unsupported cell size (PAWN_CELL_SIZE)
   1.183 +#endif
   1.184 +
   1.185 +#define UNPACKEDMAX   (((cell)1 << (sizeof(cell)-1)*8) - 1)
   1.186 +#define UNLIMITED     (~1u >> 1)
   1.187 +
   1.188 +struct tagAMX;
   1.189 +typedef cell (AMX_NATIVE_CALL *AMX_NATIVE)(struct tagAMX *amx, cell *params);
   1.190 +typedef int (AMXAPI *AMX_CALLBACK)(struct tagAMX *amx, cell index,
   1.191 +                                   cell *result, cell *params);
   1.192 +typedef int (AMXAPI *AMX_DEBUG)(struct tagAMX *amx);
   1.193 +typedef int (AMXAPI *AMX_IDLE)(struct tagAMX *amx, int AMXAPI Exec(struct tagAMX *, cell *, int));
   1.194 +#if !defined _FAR
   1.195 +  #define _FAR
   1.196 +#endif
   1.197 +
   1.198 +#if defined _MSC_VER
   1.199 +  #pragma warning(disable:4103)  /* disable warning message 4103 that complains
   1.200 +                                  * about pragma pack in a header file */
   1.201 +  #pragma warning(disable:4100)  /* "'%$S' : unreferenced formal parameter" */
   1.202 +#endif
   1.203 +
   1.204 +/* Some compilers do not support the #pragma align, which should be fine. Some
   1.205 + * compilers give a warning on unknown #pragmas, which is not so fine...
   1.206 + */
   1.207 +#if (defined SN_TARGET_PS2 || defined __GNUC__) && !defined AMX_NO_ALIGN
   1.208 +  #define AMX_NO_ALIGN
   1.209 +#endif
   1.210 +
   1.211 +#if defined __GNUC__
   1.212 +  #define PACKED        __attribute__((packed))
   1.213 +#else
   1.214 +  #define PACKED
   1.215 +#endif
   1.216 +
   1.217 +#if !defined AMX_NO_ALIGN
   1.218 +  #if defined LINUX || defined __FreeBSD__
   1.219 +    #pragma pack(1)         /* structures must be packed (byte-aligned) */
   1.220 +  #elif defined MACOS && defined __MWERKS__
   1.221 +	#pragma options align=mac68k
   1.222 +  #else
   1.223 +    #pragma pack(push)
   1.224 +    #pragma pack(1)         /* structures must be packed (byte-aligned) */
   1.225 +    #if defined __TURBOC__
   1.226 +      #pragma option -a-    /* "pack" pragma for older Borland compilers */
   1.227 +    #endif
   1.228 +  #endif
   1.229 +#endif
   1.230 +
   1.231 +typedef struct tagAMX_NATIVE_INFO {
   1.232 +  const char _FAR *name PACKED;
   1.233 +  AMX_NATIVE func       PACKED;
   1.234 +} AMX_NATIVE_INFO;
   1.235 +
   1.236 +#define AMX_USERNUM     4
   1.237 +#define sEXPMAX         19      /* maximum name length for file version <= 6 */
   1.238 +#define sNAMEMAX        31      /* maximum name length of symbol name */
   1.239 +
   1.240 +typedef struct tagAMX_FUNCSTUB {
   1.241 +  ucell address         PACKED;
   1.242 +  char name[sEXPMAX+1]  PACKED;
   1.243 +} AMX_FUNCSTUB;
   1.244 +
   1.245 +typedef struct tagFUNCSTUBNT {
   1.246 +  ucell address         PACKED;
   1.247 +  uint32_t nameofs      PACKED;
   1.248 +} AMX_FUNCSTUBNT;
   1.249 +
   1.250 +/* The AMX structure is the internal structure for many functions. Not all
   1.251 + * fields are valid at all times; many fields are cached in local variables.
   1.252 + */
   1.253 +typedef struct tagAMX {
   1.254 +  unsigned char _FAR *base PACKED; /* points to the AMX header plus the code, optionally also the data */
   1.255 +  unsigned char _FAR *data PACKED; /* points to separate data+stack+heap, may be NULL */
   1.256 +  AMX_CALLBACK callback PACKED;
   1.257 +  AMX_DEBUG debug       PACKED; /* debug callback */
   1.258 +  /* for external functions a few registers must be accessible from the outside */
   1.259 +  cell cip              PACKED; /* instruction pointer: relative to base + amxhdr->cod */
   1.260 +  cell frm              PACKED; /* stack frame base: relative to base + amxhdr->dat */
   1.261 +  cell hea              PACKED; /* top of the heap: relative to base + amxhdr->dat */
   1.262 +  cell hlw              PACKED; /* bottom of the heap: relative to base + amxhdr->dat */
   1.263 +  cell stk              PACKED; /* stack pointer: relative to base + amxhdr->dat */
   1.264 +  cell stp              PACKED; /* top of the stack: relative to base + amxhdr->dat */
   1.265 +  int flags             PACKED; /* current status, see amx_Flags() */
   1.266 +  /* user data */
   1.267 +  long usertags[AMX_USERNUM] PACKED;
   1.268 +  void _FAR *userdata[AMX_USERNUM] PACKED;
   1.269 +  /* native functions can raise an error */
   1.270 +  int error             PACKED;
   1.271 +  /* passing parameters requires a "count" field */
   1.272 +  int paramcount;
   1.273 +  /* the sleep opcode needs to store the full AMX status */
   1.274 +  cell pri              PACKED;
   1.275 +  cell alt              PACKED;
   1.276 +  cell reset_stk        PACKED;
   1.277 +  cell reset_hea        PACKED;
   1.278 +  cell sysreq_d         PACKED; /* relocated address/value for the SYSREQ.D opcode */
   1.279 +  #if defined JIT
   1.280 +    /* support variables for the JIT */
   1.281 +    int reloc_size      PACKED; /* required temporary buffer for relocations */
   1.282 +    long code_size      PACKED; /* estimated memory footprint of the native code */
   1.283 +  #endif
   1.284 +} AMX;
   1.285 +
   1.286 +/* The AMX_HEADER structure is both the memory format as the file format. The
   1.287 + * structure is used internaly.
   1.288 + */
   1.289 +typedef struct tagAMX_HEADER {
   1.290 +  int32_t size          PACKED; /* size of the "file" */
   1.291 +  uint16_t magic        PACKED; /* signature */
   1.292 +  char    file_version  PACKED; /* file format version */
   1.293 +  char    amx_version   PACKED; /* required version of the AMX */
   1.294 +  int16_t flags         PACKED;
   1.295 +  int16_t defsize       PACKED; /* size of a definition record */
   1.296 +  int32_t cod           PACKED; /* initial value of COD - code block */
   1.297 +  int32_t dat           PACKED; /* initial value of DAT - data block */
   1.298 +  int32_t hea           PACKED; /* initial value of HEA - start of the heap */
   1.299 +  int32_t stp           PACKED; /* initial value of STP - stack top */
   1.300 +  int32_t cip           PACKED; /* initial value of CIP - the instruction pointer */
   1.301 +  int32_t publics       PACKED; /* offset to the "public functions" table */
   1.302 +  int32_t natives       PACKED; /* offset to the "native functions" table */
   1.303 +  int32_t libraries     PACKED; /* offset to the table of libraries */
   1.304 +  int32_t pubvars       PACKED; /* the "public variables" table */
   1.305 +  int32_t tags          PACKED; /* the "public tagnames" table */
   1.306 +  int32_t nametable     PACKED; /* name table */
   1.307 +} AMX_HEADER;
   1.308 +
   1.309 +#if PAWN_CELL_SIZE==16
   1.310 +  #define AMX_MAGIC     0xf1e2
   1.311 +#elif PAWN_CELL_SIZE==32
   1.312 +  #define AMX_MAGIC     0xf1e0
   1.313 +#elif PAWN_CELL_SIZE==64
   1.314 +  #define AMX_MAGIC     0xf1e1
   1.315 +#endif
   1.316 +
   1.317 +enum {
   1.318 +  AMX_ERR_NONE,
   1.319 +  /* reserve the first 15 error codes for exit codes of the abstract machine */
   1.320 +  AMX_ERR_EXIT,         /* forced exit */
   1.321 +  AMX_ERR_ASSERT,       /* assertion failed */
   1.322 +  AMX_ERR_STACKERR,     /* stack/heap collision */
   1.323 +  AMX_ERR_BOUNDS,       /* index out of bounds */
   1.324 +  AMX_ERR_MEMACCESS,    /* invalid memory access */
   1.325 +  AMX_ERR_INVINSTR,     /* invalid instruction */
   1.326 +  AMX_ERR_STACKLOW,     /* stack underflow */
   1.327 +  AMX_ERR_HEAPLOW,      /* heap underflow */
   1.328 +  AMX_ERR_CALLBACK,     /* no callback, or invalid callback */
   1.329 +  AMX_ERR_NATIVE,       /* native function failed */
   1.330 +  AMX_ERR_DIVIDE,       /* divide by zero */
   1.331 +  AMX_ERR_SLEEP,        /* go into sleepmode - code can be restarted */
   1.332 +  AMX_ERR_INVSTATE,     /* invalid state for this access */
   1.333 +
   1.334 +  AMX_ERR_MEMORY = 16,  /* out of memory */
   1.335 +  AMX_ERR_FORMAT,       /* invalid file format */
   1.336 +  AMX_ERR_VERSION,      /* file is for a newer version of the AMX */
   1.337 +  AMX_ERR_NOTFOUND,     /* function not found */
   1.338 +  AMX_ERR_INDEX,        /* invalid index parameter (bad entry point) */
   1.339 +  AMX_ERR_DEBUG,        /* debugger cannot run */
   1.340 +  AMX_ERR_INIT,         /* AMX not initialized (or doubly initialized) */
   1.341 +  AMX_ERR_USERDATA,     /* unable to set user data field (table full) */
   1.342 +  AMX_ERR_INIT_JIT,     /* cannot initialize the JIT */
   1.343 +  AMX_ERR_PARAMS,       /* parameter error */
   1.344 +  AMX_ERR_DOMAIN,       /* domain error, expression result does not fit in range */
   1.345 +  AMX_ERR_GENERAL,      /* general error (unknown or unspecific error) */
   1.346 +};
   1.347 +
   1.348 +/*      AMX_FLAG_CHAR16   0x01     no longer used */
   1.349 +#define AMX_FLAG_DEBUG    0x02  /* symbolic info. available */
   1.350 +#define AMX_FLAG_COMPACT  0x04  /* compact encoding */
   1.351 +#define AMX_FLAG_SLEEP    0x08  /* script uses the sleep instruction (possible re-entry or power-down mode) */
   1.352 +#define AMX_FLAG_NOCHECKS 0x10  /* no array bounds checking; no BREAK opcodes */
   1.353 +#define AMX_FLAG_NTVREG 0x1000  /* all native functions are registered */
   1.354 +#define AMX_FLAG_JITC   0x2000  /* abstract machine is JIT compiled */
   1.355 +#define AMX_FLAG_BROWSE 0x4000  /* busy browsing */
   1.356 +#define AMX_FLAG_RELOC  0x8000  /* jump/call addresses relocated */
   1.357 +
   1.358 +#define AMX_EXEC_MAIN   (-1)    /* start at program entry point */
   1.359 +#define AMX_EXEC_CONT   (-2)    /* continue from last address */
   1.360 +
   1.361 +#define AMX_USERTAG(a,b,c,d)    ((a) | ((b)<<8) | ((long)(c)<<16) | ((long)(d)<<24))
   1.362 +
   1.363 +#if !defined AMX_COMPACTMARGIN
   1.364 +  #define AMX_COMPACTMARGIN 64
   1.365 +#endif
   1.366 +
   1.367 +/* for native functions that use floating point parameters, the following
   1.368 + * two macros are convenient for casting a "cell" into a "float" type _without_
   1.369 + * changing the bit pattern
   1.370 + */
   1.371 +#if PAWN_CELL_SIZE==32
   1.372 +  #define amx_ftoc(f)   ( * ((cell*)&f) )   /* float to cell */
   1.373 +  #define amx_ctof(c)   ( * ((float*)&c) )  /* cell to float */
   1.374 +#elif PAWN_CELL_SIZE==64
   1.375 +  #define amx_ftoc(f)   ( * ((cell*)&f) )   /* float to cell */
   1.376 +  #define amx_ctof(c)   ( * ((double*)&c) ) /* cell to float */
   1.377 +#else
   1.378 +  #error Unsupported cell size
   1.379 +#endif
   1.380 +
   1.381 +#define amx_StrParam(amx,param,result)                                      \
   1.382 +    do {                                                                    \
   1.383 +      cell *amx_cstr_; int amx_length_;                                     \
   1.384 +      amx_GetAddr((amx), (param), &amx_cstr_);                              \
   1.385 +      amx_StrLen(amx_cstr_, &amx_length_);                                  \
   1.386 +      if (amx_length_ > 0 &&                                                \
   1.387 +          ((result) = (void*)alloca((amx_length_ + 1) * sizeof(*(result)))) != NULL) \
   1.388 +        amx_GetString((char*)(result), amx_cstr_, sizeof(*(result))>1, amx_length_ + 1); \
   1.389 +      else (result) = NULL;                                                 \
   1.390 +    } while (0)
   1.391 +
   1.392 +uint16_t * AMXAPI amx_Align16(uint16_t *v);
   1.393 +uint32_t * AMXAPI amx_Align32(uint32_t *v);
   1.394 +#if defined _I64_MAX || defined HAVE_I64
   1.395 +  uint64_t * AMXAPI amx_Align64(uint64_t *v);
   1.396 +#endif
   1.397 +int AMXAPI amx_Allot(AMX *amx, int cells, cell *amx_addr, cell **phys_addr);
   1.398 +int AMXAPI amx_Callback(AMX *amx, cell index, cell *result, cell *params);
   1.399 +int AMXAPI amx_Cleanup(AMX *amx);
   1.400 +int AMXAPI amx_Clone(AMX *amxClone, AMX *amxSource, void *data);
   1.401 +int AMXAPI amx_Exec(AMX *amx, cell *retval, int index);
   1.402 +int AMXAPI amx_FindNative(AMX *amx, const char *name, int *index);
   1.403 +int AMXAPI amx_FindPublic(AMX *amx, const char *funcname, int *index);
   1.404 +int AMXAPI amx_FindPubVar(AMX *amx, const char *varname, cell *amx_addr);
   1.405 +int AMXAPI amx_FindTagId(AMX *amx, cell tag_id, char *tagname);
   1.406 +int AMXAPI amx_Flags(AMX *amx,uint16_t *flags);
   1.407 +int AMXAPI amx_GetAddr(AMX *amx,cell amx_addr,cell **phys_addr);
   1.408 +int AMXAPI amx_GetNative(AMX *amx, int index, char *funcname);
   1.409 +int AMXAPI amx_GetPublic(AMX *amx, int index, char *funcname);
   1.410 +int AMXAPI amx_GetPubVar(AMX *amx, int index, char *varname, cell *amx_addr);
   1.411 +int AMXAPI amx_GetString(char *dest,const cell *source, int use_wchar, size_t size);
   1.412 +int AMXAPI amx_GetTag(AMX *amx, int index, char *tagname, cell *tag_id);
   1.413 +int AMXAPI amx_GetUserData(AMX *amx, long tag, void **ptr);
   1.414 +int AMXAPI amx_Init(AMX *amx, void *program);
   1.415 +int AMXAPI amx_InitJIT(AMX *amx, void *reloc_table, void *native_code);
   1.416 +int AMXAPI amx_MemInfo(AMX *amx, long *codesize, long *datasize, long *stackheap);
   1.417 +int AMXAPI amx_NameLength(AMX *amx, int *length);
   1.418 +AMX_NATIVE_INFO * AMXAPI amx_NativeInfo(const char *name, AMX_NATIVE func);
   1.419 +int AMXAPI amx_NumNatives(AMX *amx, int *number);
   1.420 +int AMXAPI amx_NumPublics(AMX *amx, int *number);
   1.421 +int AMXAPI amx_NumPubVars(AMX *amx, int *number);
   1.422 +int AMXAPI amx_NumTags(AMX *amx, int *number);
   1.423 +int AMXAPI amx_Push(AMX *amx, cell value);
   1.424 +int AMXAPI amx_PushArray(AMX *amx, cell *amx_addr, cell **phys_addr, const cell array[], int numcells);
   1.425 +int AMXAPI amx_PushString(AMX *amx, cell *amx_addr, cell **phys_addr, const char *string, int pack, int use_wchar);
   1.426 +int AMXAPI amx_RaiseError(AMX *amx, int error);
   1.427 +int AMXAPI amx_Register(AMX *amx, const AMX_NATIVE_INFO *nativelist, int number);
   1.428 +int AMXAPI amx_Release(AMX *amx, cell amx_addr);
   1.429 +int AMXAPI amx_SetCallback(AMX *amx, AMX_CALLBACK callback);
   1.430 +int AMXAPI amx_SetDebugHook(AMX *amx, AMX_DEBUG debug);
   1.431 +int AMXAPI amx_SetString(cell *dest, const char *source, int pack, int use_wchar, size_t size);
   1.432 +int AMXAPI amx_SetUserData(AMX *amx, long tag, void *ptr);
   1.433 +int AMXAPI amx_StrLen(const cell *cstring, int *length);
   1.434 +int AMXAPI amx_UTF8Check(const char *string, int *length);
   1.435 +int AMXAPI amx_UTF8Get(const char *string, const char **endptr, cell *value);
   1.436 +int AMXAPI amx_UTF8Len(const cell *cstr, int *length);
   1.437 +int AMXAPI amx_UTF8Put(char *string, char **endptr, int maxchars, cell value);
   1.438 +
   1.439 +#if PAWN_CELL_SIZE==16
   1.440 +  #define amx_AlignCell(v) amx_Align16(v)
   1.441 +#elif PAWN_CELL_SIZE==32
   1.442 +  #define amx_AlignCell(v) amx_Align32(v)
   1.443 +#elif PAWN_CELL_SIZE==64 && (defined _I64_MAX || defined HAVE_I64)
   1.444 +  #define amx_AlignCell(v) amx_Align64(v)
   1.445 +#else
   1.446 +  #error Unsupported cell size
   1.447 +#endif
   1.448 +
   1.449 +#define amx_RegisterFunc(amx, name, func) \
   1.450 +  amx_Register((amx), amx_NativeInfo((name),(func)), 1);
   1.451 +
   1.452 +#if !defined AMX_NO_ALIGN
   1.453 +  #if defined LINUX || defined __FreeBSD__
   1.454 +    #pragma pack()    /* reset default packing */
   1.455 +  #elif defined MACOS && defined __MWERKS__
   1.456 +    #pragma options align=reset
   1.457 +  #else
   1.458 +    #pragma pack(pop) /* reset previous packing */
   1.459 +  #endif
   1.460 +#endif
   1.461 +
   1.462 +#ifdef  __cplusplus
   1.463 +}
   1.464 +#endif
   1.465 +
   1.466 +typedef enum {
   1.467 +  OP_NONE,              /* invalid opcode */
   1.468 +  OP_LOAD_PRI,
   1.469 +  OP_LOAD_ALT,
   1.470 +  OP_LOAD_S_PRI,
   1.471 +  OP_LOAD_S_ALT,
   1.472 +  OP_LREF_PRI,
   1.473 +  OP_LREF_ALT,
   1.474 +  OP_LREF_S_PRI,
   1.475 +  OP_LREF_S_ALT,
   1.476 +  OP_LOAD_I,
   1.477 +  OP_LODB_I,
   1.478 +  OP_CONST_PRI,
   1.479 +  OP_CONST_ALT,
   1.480 +  OP_ADDR_PRI,
   1.481 +  OP_ADDR_ALT,
   1.482 +  OP_STOR_PRI,
   1.483 +  OP_STOR_ALT,
   1.484 +  OP_STOR_S_PRI,
   1.485 +  OP_STOR_S_ALT,
   1.486 +  OP_SREF_PRI,
   1.487 +  OP_SREF_ALT,
   1.488 +  OP_SREF_S_PRI,
   1.489 +  OP_SREF_S_ALT,
   1.490 +  OP_STOR_I,
   1.491 +  OP_STRB_I,
   1.492 +  OP_LIDX,
   1.493 +  OP_LIDX_B,
   1.494 +  OP_IDXADDR,
   1.495 +  OP_IDXADDR_B,
   1.496 +  OP_ALIGN_PRI,
   1.497 +  OP_ALIGN_ALT,
   1.498 +  OP_LCTRL,
   1.499 +  OP_SCTRL,
   1.500 +  OP_MOVE_PRI,
   1.501 +  OP_MOVE_ALT,
   1.502 +  OP_XCHG,
   1.503 +  OP_PUSH_PRI,
   1.504 +  OP_PUSH_ALT,
   1.505 +  OP_PUSH_R,
   1.506 +  OP_PUSH_C,
   1.507 +  OP_PUSH,
   1.508 +  OP_PUSH_S,
   1.509 +  OP_POP_PRI,
   1.510 +  OP_POP_ALT,
   1.511 +  OP_STACK,
   1.512 +  OP_HEAP,
   1.513 +  OP_PROC,
   1.514 +  OP_RET,
   1.515 +  OP_RETN,
   1.516 +  OP_CALL,
   1.517 +  OP_CALL_PRI,
   1.518 +  OP_JUMP,
   1.519 +  OP_JREL,
   1.520 +  OP_JZER,
   1.521 +  OP_JNZ,
   1.522 +  OP_JEQ,
   1.523 +  OP_JNEQ,
   1.524 +  OP_JLESS,
   1.525 +  OP_JLEQ,
   1.526 +  OP_JGRTR,
   1.527 +  OP_JGEQ,
   1.528 +  OP_JSLESS,
   1.529 +  OP_JSLEQ,
   1.530 +  OP_JSGRTR,
   1.531 +  OP_JSGEQ,
   1.532 +  OP_SHL,
   1.533 +  OP_SHR,
   1.534 +  OP_SSHR,
   1.535 +  OP_SHL_C_PRI,
   1.536 +  OP_SHL_C_ALT,
   1.537 +  OP_SHR_C_PRI,
   1.538 +  OP_SHR_C_ALT,
   1.539 +  OP_SMUL,
   1.540 +  OP_SDIV,
   1.541 +  OP_SDIV_ALT,
   1.542 +  OP_UMUL,
   1.543 +  OP_UDIV,
   1.544 +  OP_UDIV_ALT,
   1.545 +  OP_ADD,
   1.546 +  OP_SUB,
   1.547 +  OP_SUB_ALT,
   1.548 +  OP_AND,
   1.549 +  OP_OR,
   1.550 +  OP_XOR,
   1.551 +  OP_NOT,
   1.552 +  OP_NEG,
   1.553 +  OP_INVERT,
   1.554 +  OP_ADD_C,
   1.555 +  OP_SMUL_C,
   1.556 +  OP_ZERO_PRI,
   1.557 +  OP_ZERO_ALT,
   1.558 +  OP_ZERO,
   1.559 +  OP_ZERO_S,
   1.560 +  OP_SIGN_PRI,
   1.561 +  OP_SIGN_ALT,
   1.562 +  OP_EQ,
   1.563 +  OP_NEQ,
   1.564 +  OP_LESS,
   1.565 +  OP_LEQ,
   1.566 +  OP_GRTR,
   1.567 +  OP_GEQ,
   1.568 +  OP_SLESS,
   1.569 +  OP_SLEQ,
   1.570 +  OP_SGRTR,
   1.571 +  OP_SGEQ,
   1.572 +  OP_EQ_C_PRI,
   1.573 +  OP_EQ_C_ALT,
   1.574 +  OP_INC_PRI,
   1.575 +  OP_INC_ALT,
   1.576 +  OP_INC,
   1.577 +  OP_INC_S,
   1.578 +  OP_INC_I,
   1.579 +  OP_DEC_PRI,
   1.580 +  OP_DEC_ALT,
   1.581 +  OP_DEC,
   1.582 +  OP_DEC_S,
   1.583 +  OP_DEC_I,
   1.584 +  OP_MOVS,
   1.585 +  OP_CMPS,
   1.586 +  OP_FILL,
   1.587 +  OP_HALT,
   1.588 +  OP_BOUNDS,
   1.589 +  OP_SYSREQ_PRI,
   1.590 +  OP_SYSREQ_C,
   1.591 +  OP_FILE,    /* obsolete */
   1.592 +  OP_LINE,    /* obsolete */
   1.593 +  OP_SYMBOL,  /* obsolete */
   1.594 +  OP_SRANGE,  /* obsolete */
   1.595 +  OP_JUMP_PRI,
   1.596 +  OP_SWITCH,
   1.597 +  OP_CASETBL,
   1.598 +  OP_SWAP_PRI,
   1.599 +  OP_SWAP_ALT,
   1.600 +  OP_PUSH_ADR,
   1.601 +  OP_NOP,
   1.602 +  OP_SYSREQ_N,
   1.603 +  OP_SYMTAG,  /* obsolete */
   1.604 +  OP_BREAK,
   1.605 +  OP_PUSH2_C,
   1.606 +  OP_PUSH2,
   1.607 +  OP_PUSH2_S,
   1.608 +  OP_PUSH2_ADR,
   1.609 +  OP_PUSH3_C,
   1.610 +  OP_PUSH3,
   1.611 +  OP_PUSH3_S,
   1.612 +  OP_PUSH3_ADR,
   1.613 +  OP_PUSH4_C,
   1.614 +  OP_PUSH4,
   1.615 +  OP_PUSH4_S,
   1.616 +  OP_PUSH4_ADR,
   1.617 +  OP_PUSH5_C,
   1.618 +  OP_PUSH5,
   1.619 +  OP_PUSH5_S,
   1.620 +  OP_PUSH5_ADR,
   1.621 +  OP_LOAD_BOTH,
   1.622 +  OP_LOAD_S_BOTH,
   1.623 +  OP_CONST,
   1.624 +  OP_CONST_S,
   1.625 +  /* ----- */
   1.626 +  OP_SYSREQ_D,
   1.627 +  OP_SYSREQ_ND,
   1.628 +  /* ----- */
   1.629 +  OP_NUM_OPCODES
   1.630 +} OPCODE;
   1.631 +
   1.632 +#endif /* AMX_H_INCLUDED */