LLP64 platform so it's unsafe to cast pointers to unsigned long.
Reported by: Chris Tophe <cohika@gmail.com>
svn path=/trunk/yasm/; revision=1774
test_hd_SOURCES = test_hd.c
include_HEADERS = libyasm.h
+include_HEADERS += libyasm-stdint.h
noinst_HEADERS = util.h
CLEANFILES = configure.lineno
EXTRA_DIST = config/config.rpath
-# _stdint.h doesn't clean up after itself?
-CONFIG_CLEAN_FILES = _stdint.h
+# libyasm-stdint.h doesn't clean up after itself?
+CONFIG_CLEAN_FILES = libyasm-stdint.h
# automake doesn't distribute mkinstalldirs?
EXTRA_DIST += config/mkinstalldirs
EXTRA_DIST += Mkfiles/Makefile.flat
EXTRA_DIST += Mkfiles/Makefile.dj
EXTRA_DIST += Mkfiles/dj/config.h
-EXTRA_DIST += Mkfiles/dj/_stdint.h
+EXTRA_DIST += Mkfiles/dj/libyasm-stdint.h
EXTRA_DIST += Mkfiles/vc/yasm.sln
EXTRA_DIST += Mkfiles/vc/yasm.vcproj
EXTRA_DIST += Mkfiles/vc/config.h
-EXTRA_DIST += Mkfiles/vc/_stdint.h
+EXTRA_DIST += Mkfiles/vc/libyasm-stdint.h
EXTRA_DIST += Mkfiles/vc/genmacro/genmacro.vcproj
EXTRA_DIST += Mkfiles/vc/genmacro/run.bat
EXTRA_DIST += Mkfiles/vc/genmodule/genmodule.vcproj
EXTRA_DIST += Mkfiles/vc8/yasm.sln
EXTRA_DIST += Mkfiles/vc8/yasm.vcproj
EXTRA_DIST += Mkfiles/vc8/config.h
-EXTRA_DIST += Mkfiles/vc8/_stdint.h
+EXTRA_DIST += Mkfiles/vc8/libyasm-stdint.h
EXTRA_DIST += Mkfiles/vc8/readme.vc8.txt
EXTRA_DIST += Mkfiles/vc8/yasm.rules
EXTRA_DIST += Mkfiles/vc8/genmacro/genmacro.vcproj
AC_C_INLINE
AC_C_PROTOTYPES
AC_TYPE_SIZE_T
-AX_CREATE_STDINT_H
+AX_CREATE_STDINT_H([libyasm-stdint.h])
#
# Checks for library functions.
typedef struct __FILE FILE;
typedef struct __va_list va_list;
typedef unsigned long size_t;
+typedef unsigned long uintptr_t;
#else
#include <stdio.h>
#include <stdarg.h>
+#include <libyasm-stdint.h>
#endif
#ifdef YASM_LIB_INTERNAL
yasm_insn_operand *
-yasm_operand_create_reg(unsigned long reg)
+yasm_operand_create_reg(uintptr_t reg)
{
yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand));
}
yasm_insn_operand *
-yasm_operand_create_segreg(unsigned long segreg)
+yasm_operand_create_segreg(uintptr_t segreg)
{
yasm_insn_operand *retval = yasm_xmalloc(sizeof(yasm_insn_operand));
yasm_operand_create_imm(/*@only@*/ yasm_expr *val)
{
yasm_insn_operand *retval;
- const unsigned long *reg;
+ const uintptr_t *reg;
reg = yasm_expr_get_reg(&val, 0);
if (reg) {
* Call yasm_arch_parse_check_insnprefix() instead of calling this function.
*/
yasm_arch_insnprefix (*parse_check_insnprefix)
- (yasm_arch *arch, /*@out@*/ unsigned long data[4], const char *id,
+ (yasm_arch *arch, /*@out@*/ uintptr_t data[4], const char *id,
size_t id_len);
/** Module-level implementation of yasm_arch_parse_check_regtmod().
* Call yasm_arch_parse_check_regtmod() instead of calling this function.
*/
yasm_arch_regtmod (*parse_check_regtmod)
- (yasm_arch *arch, /*@out@*/ unsigned long *data, const char *id,
+ (yasm_arch *arch, /*@out@*/ uintptr_t *data, const char *id,
size_t id_len);
/** Module-level implementation of yasm_arch_parse_directive().
*/
void (*finalize_insn)
(yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc,
- const unsigned long data[4], int num_operands,
+ const uintptr_t data[4], int num_operands,
/*@null@*/ yasm_insn_operands *operands, int num_prefixes,
- unsigned long **prefixes, int num_segregs,
- const unsigned long *segregs);
+ uintptr_t **prefixes, int num_segregs, const uintptr_t *segregs);
/** Module-level implementation of yasm_arch_floatnum_tobytes().
* Call yasm_arch_floatnum_tobytes() instead of calling this function.
/** Module-level implementation of yasm_arch_get_reg_size().
* Call yasm_arch_get_reg_size() instead of calling this function.
*/
- unsigned int (*get_reg_size) (yasm_arch *arch, unsigned long reg);
+ unsigned int (*get_reg_size) (yasm_arch *arch, uintptr_t reg);
/** Module-level implementation of yasm_arch_reggroup_get_reg().
* Call yasm_arch_reggroup_get_reg() instead of calling this function.
*/
- unsigned long (*reggroup_get_reg) (yasm_arch *arch, unsigned long reggroup,
- unsigned long regindex);
+ uintptr_t (*reggroup_get_reg) (yasm_arch *arch, uintptr_t reggroup,
+ unsigned long regindex);
/** Module-level implementation of yasm_arch_reg_print().
* Call yasm_arch_reg_print() instead of calling this function.
*/
- void (*reg_print) (yasm_arch *arch, unsigned long reg, FILE *f);
+ void (*reg_print) (yasm_arch *arch, uintptr_t reg, FILE *f);
/** Module-level implementation of yasm_arch_segreg_print().
* Call yasm_arch_segreg_print() instead of calling this function.
*/
- void (*segreg_print) (yasm_arch *arch, unsigned long segreg, FILE *f);
+ void (*segreg_print) (yasm_arch *arch, uintptr_t segreg, FILE *f);
/** Module-level implementation of yasm_arch_ea_create().
* Call yasm_arch_ea_create() instead of calling this function.
/** Operand data. */
union {
- unsigned long reg; /**< Arch data for reg/segreg. */
+ uintptr_t reg; /**< Arch data for reg/segreg. */
yasm_effaddr *ea; /**< Effective address for memory references. */
yasm_expr *val; /**< Value of immediate or jump target. */
} data;
- unsigned long targetmod; /**< Arch target modifier, 0 if none. */
+ uintptr_t targetmod; /**< Arch target modifier, 0 if none. */
/** Specified size of the operand, in bytes. 0 if not user-specified. */
- unsigned int size;
+ unsigned int size:8;
/** Nonzero if dereference. Used for "*foo" in GAS.
* The reason for this is that by default in GAS, an unprefixed value
* \return Identifier type (#YASM_ARCH_NOTINSNPREFIX if unrecognized)
*/
yasm_arch_insnprefix yasm_arch_parse_check_insnprefix
- (yasm_arch *arch, /*@out@*/ unsigned long data[4], const char *id,
+ (yasm_arch *arch, /*@out@*/ uintptr_t data[4], const char *id,
size_t id_len);
/** Check an generic identifier to see if it matches architecture specific
* \return Identifier type (#YASM_ARCH_NOTREGTMOD if unrecognized)
*/
yasm_arch_regtmod yasm_arch_parse_check_regtmod
- (yasm_arch *arch, /*@out@*/ unsigned long *data, const char *id,
+ (yasm_arch *arch, /*@out@*/ uintptr_t *data, const char *id,
size_t id_len);
/** Handle architecture-specific directives.
*/
void yasm_arch_finalize_insn
(yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc,
- const unsigned long data[4], int num_operands,
+ const uintptr_t data[4], int num_operands,
/*@null@*/ yasm_insn_operands *operands, int num_prefixes,
- const unsigned long **prefixes, int num_segregs,
- const unsigned long *segregs);
+ const uintptr_t **prefixes, int num_segregs, const uintptr_t *segregs);
/** Output #yasm_floatnum to buffer. Puts the value into the least
* significant bits of the destination, or may be shifted into more
* \param reg register
* \return 0 if there is no suitable equivalent size, otherwise the size.
*/
-unsigned int yasm_arch_get_reg_size(yasm_arch *arch, unsigned long reg);
+unsigned int yasm_arch_get_reg_size(yasm_arch *arch, uintptr_t reg);
/** Get a specific register of a register group, based on the register
* group and the index within the group.
* \return 0 if regindex is not valid for that register group, otherwise the
* specific register value.
*/
-unsigned long yasm_arch_reggroup_get_reg(yasm_arch *arch,
- unsigned long reggroup,
- unsigned long regindex);
+uintptr_t yasm_arch_reggroup_get_reg(yasm_arch *arch, uintptr_t reggroup,
+ unsigned long regindex);
/** Print a register. For debugging purposes.
* \param arch architecture
* \param reg register
* \param f file
*/
-void yasm_arch_reg_print(yasm_arch *arch, unsigned long reg, FILE *f);
+void yasm_arch_reg_print(yasm_arch *arch, uintptr_t reg, FILE *f);
/** Print a segment register. For debugging purposes.
* \param arch architecture
* \param segreg segment register
* \param f file
*/
-void yasm_arch_segreg_print(yasm_arch *arch, unsigned long segreg, FILE *f);
+void yasm_arch_segreg_print(yasm_arch *arch, uintptr_t segreg, FILE *f);
/** Create an effective address from an expression.
* \param arch architecture
* \param reg register
* \return Newly allocated operand.
*/
-yasm_insn_operand *yasm_operand_create_reg(unsigned long reg);
+yasm_insn_operand *yasm_operand_create_reg(uintptr_t reg);
/** Create an instruction operand from a segment register.
* \param segreg segment register
* \return Newly allocated operand.
*/
-yasm_insn_operand *yasm_operand_create_segreg(unsigned long segreg);
+yasm_insn_operand *yasm_operand_create_segreg(uintptr_t segreg);
/** Create an instruction operand from an effective address.
* \param ea effective address
typedef struct bytecode_insn {
/*@dependent@*/ yasm_arch *arch;
- unsigned long insn_data[4];
+ uintptr_t insn_data[4];
int num_operands;
/*@null@*/ yasm_insn_operands operands;
/* array of 4-element prefix_data arrays */
int num_prefixes;
- /*@null@*/ unsigned long **prefixes;
+ /*@null@*/ uintptr_t **prefixes;
/* array of segment prefixes */
int num_segregs;
- /*@null@*/ unsigned long *segregs;
+ /*@null@*/ uintptr_t *segregs;
} bytecode_insn;
static void bc_insn_destroy(void *contents);
}
void
-yasm_ea_set_segreg(yasm_effaddr *ea, unsigned long segreg)
+yasm_ea_set_segreg(yasm_effaddr *ea, uintptr_t segreg)
{
if (!ea)
return;
}
yasm_bytecode *
-yasm_bc_create_insn(yasm_arch *arch, const unsigned long insn_data[4],
+yasm_bc_create_insn(yasm_arch *arch, const uintptr_t insn_data[4],
int num_operands, /*@null@*/ yasm_insn_operands *operands,
unsigned long line)
{
}
void
-yasm_bc_insn_add_prefix(yasm_bytecode *bc, const unsigned long prefix_data[4])
+yasm_bc_insn_add_prefix(yasm_bytecode *bc, const uintptr_t prefix_data[4])
{
bytecode_insn *insn = (bytecode_insn *)bc->contents;
insn->prefixes =
yasm_xrealloc(insn->prefixes,
- (insn->num_prefixes+1)*sizeof(unsigned long *));
- insn->prefixes[insn->num_prefixes] =
- yasm_xmalloc(4*sizeof(unsigned long));
+ (insn->num_prefixes+1)*sizeof(uintptr_t *));
+ insn->prefixes[insn->num_prefixes] = yasm_xmalloc(4*sizeof(uintptr_t));
insn->prefixes[insn->num_prefixes][0] = prefix_data[0];
insn->prefixes[insn->num_prefixes][1] = prefix_data[1];
insn->prefixes[insn->num_prefixes][2] = prefix_data[2];
}
void
-yasm_bc_insn_add_seg_prefix(yasm_bytecode *bc, unsigned long segreg)
+yasm_bc_insn_add_seg_prefix(yasm_bytecode *bc, uintptr_t segreg)
{
bytecode_insn *insn = (bytecode_insn *)bc->contents;
assert(bc->callback == bc_insn_callback);
insn->segregs =
- yasm_xrealloc(insn->segregs,
- (insn->num_segregs+1)*sizeof(unsigned long));
+ yasm_xrealloc(insn->segregs, (insn->num_segregs+1)*sizeof(uintptr_t));
insn->segregs[insn->num_segregs] = segreg;
insn->num_segregs++;
}
yasm_value disp; /**< address displacement */
- unsigned long segreg; /**< segment register override (0 if none) */
+ uintptr_t segreg; /**< segment register override (0 if none) */
unsigned char need_nonzero_len; /**< 1 if length of disp must be >0. */
unsigned char need_disp; /**< 1 if a displacement should be present
* \param ea effective address
* \param segreg segment register (0 if none)
*/
-void yasm_ea_set_segreg(yasm_effaddr *ea, unsigned long segreg);
+void yasm_ea_set_segreg(yasm_effaddr *ea, uintptr_t segreg);
/** Delete (free allocated memory for) an effective address.
* \param ea effective address (only pointer to it).
* giving operands to this function.
*/
/*@only@*/ yasm_bytecode *yasm_bc_create_insn
- (yasm_arch *arch, const unsigned long insn_data[4], int num_operands,
+ (yasm_arch *arch, const uintptr_t insn_data[4], int num_operands,
/*@null@*/ yasm_insn_operands *operands, unsigned long line);
/** Create a bytecode that represents a single empty (0 length) instruction.
* \param prefix_data data the identifies the prefix
*/
void yasm_bc_insn_add_prefix(yasm_bytecode *bc,
- const unsigned long prefix_data[4]);
+ const uintptr_t prefix_data[4]);
/** Associate a segment prefix with an instruction bytecode.
* \param bc instruction bytecode
* \param segreg data the identifies the segment register
*/
-void yasm_bc_insn_add_seg_prefix(yasm_bytecode *bc, unsigned long segreg);
+void yasm_bc_insn_add_seg_prefix(yasm_bytecode *bc, uintptr_t segreg);
/** Get the section that contains a particular bytecode.
* \param bc bytecode
/*@null@*/ yasm_output_reloc_func output_reloc)
/*@sets *buf@*/;
-/** Get the bytecode multiple value as an unsigned long integer.
+/** Get the bytecode multiple value as an integer.
* \param bc bytecode
* \param multiple multiple value (output)
* \param calc_bc_dist nonzero if distances between bytecodes should be
#include "coretype.h"
#include "hamt.h"
-#include "_stdint.h" /* for uintptr_t */
struct HAMTEntry {
STAILQ_ENTRY(HAMTEntry) next; /* next hash table entry */
}
unsigned int
-yasm_x86__get_reg_size(yasm_arch *arch, unsigned long reg)
+yasm_x86__get_reg_size(yasm_arch *arch, uintptr_t reg)
{
switch ((x86_expritem_reg_size)(reg & ~0xFUL)) {
case X86_REG8:
return 0;
}
-static unsigned long
-x86_reggroup_get_reg(yasm_arch *arch, unsigned long reggroup,
+static uintptr_t
+x86_reggroup_get_reg(yasm_arch *arch, uintptr_t reggroup,
unsigned long regindex)
{
yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch;
}
static void
-x86_reg_print(yasm_arch *arch, unsigned long reg, FILE *f)
+x86_reg_print(yasm_arch *arch, uintptr_t reg, FILE *f)
{
static const char *name8[] = {"al","cl","dl","bl","ah","ch","dh","bh"};
static const char *name8x[] = {
}
static void
-x86_segreg_print(yasm_arch *arch, unsigned long segreg, FILE *f)
+x86_segreg_print(yasm_arch *arch, uintptr_t segreg, FILE *f)
{
static const char *name[] = {"es","cs","ss","ds","fs","gs"};
fprintf(f, "%s", name[segreg&7]);
* in 64-bit mode or if it wasn't needed to express reg.
*/
int yasm_x86__set_rex_from_reg(unsigned char *rex, unsigned char *low3,
- unsigned long reg, unsigned int bits,
+ uintptr_t reg, unsigned int bits,
x86_rex_bit_pos rexbit);
/* Effective address type */
void yasm_x86__bc_apply_prefixes
(x86_common *common, unsigned char *rex, int num_prefixes,
- unsigned long **prefixes);
+ uintptr_t **prefixes);
/* Check an effective address. Returns 0 if EA was successfully determined,
* 1 if invalid EA, or 2 if indeterminate EA.
void yasm_x86__parse_cpu(yasm_arch *arch, const char *cpuid, size_t cpuid_len);
yasm_arch_insnprefix yasm_x86__parse_check_insnprefix
- (yasm_arch *arch, /*@out@*/ unsigned long data[4], const char *id,
+ (yasm_arch *arch, /*@out@*/ uintptr_t data[4], const char *id,
size_t id_len);
yasm_arch_regtmod yasm_x86__parse_check_regtmod
- (yasm_arch *arch, /*@out@*/ unsigned long *data, const char *id,
+ (yasm_arch *arch, /*@out@*/ uintptr_t *data, const char *id,
size_t id_len);
void yasm_x86__finalize_insn
(yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc,
- const unsigned long data[4], int num_operands,
+ const uintptr_t data[4], int num_operands,
/*@null@*/ yasm_insn_operands *operands, int num_prefixes,
- unsigned long **prefixes, int num_segregs, const unsigned long *segregs);
+ uintptr_t **prefixes, int num_segregs, const uintptr_t *segregs);
int yasm_x86__floatnum_tobytes
(yasm_arch *arch, const yasm_floatnum *flt, unsigned char *buf,
size_t destsize, size_t valsize, int shift, const yasm_bytecode *bc,
int warn);
-unsigned int yasm_x86__get_reg_size(yasm_arch *arch, unsigned long reg);
+unsigned int yasm_x86__get_reg_size(yasm_arch *arch, uintptr_t reg);
#endif
int
yasm_x86__set_rex_from_reg(unsigned char *rex, unsigned char *low3,
- unsigned long reg, unsigned int bits,
+ uintptr_t reg, unsigned int bits,
x86_rex_bit_pos rexbit)
{
*low3 = (unsigned char)(reg&7);
void
yasm_x86__bc_apply_prefixes(x86_common *common, unsigned char *rex,
- int num_prefixes, unsigned long **prefixes)
+ int num_prefixes, uintptr_t **prefixes)
{
int i;
int first = 1;
static void
x86_finalize_jmpfar(yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc,
- const unsigned long data[4], int num_operands,
+ const uintptr_t data[4], int num_operands,
yasm_insn_operands *operands, int num_prefixes,
- unsigned long **prefixes, const x86_insn_info *info)
+ uintptr_t **prefixes, const x86_insn_info *info)
{
x86_jmpfar *jmpfar;
yasm_insn_operand *op;
static void
x86_finalize_jmp(yasm_arch *arch, yasm_bytecode *bc, yasm_bytecode *prev_bc,
- const unsigned long data[4], int num_operands,
+ const uintptr_t data[4], int num_operands,
yasm_insn_operands *operands, int num_prefixes,
- unsigned long **prefixes, const x86_insn_info *jinfo)
+ uintptr_t **prefixes, const x86_insn_info *jinfo)
{
x86_jmp *jmp;
int num_info = (int)(data[1]&0xFF);
void
yasm_x86__finalize_insn(yasm_arch *arch, yasm_bytecode *bc,
- yasm_bytecode *prev_bc, const unsigned long data[4],
+ yasm_bytecode *prev_bc, const uintptr_t data[4],
int num_operands,
/*@null@*/ yasm_insn_operands *operands,
- int num_prefixes, unsigned long **prefixes,
- int num_segregs, const unsigned long *segregs)
+ int num_prefixes, uintptr_t **prefixes,
+ int num_segregs, const uintptr_t *segregs)
{
yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch;
x86_insn *insn;
}
yasm_arch_insnprefix
-yasm_x86__parse_check_insnprefix(yasm_arch *arch, unsigned long data[4],
+yasm_x86__parse_check_insnprefix(yasm_arch *arch, uintptr_t data[4],
const char *id, size_t id_len)
{
yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch;
if ((cpu & CPU_Not64) && arch_x86->mode_bits == 64) {
yasm_error_set(YASM_ERROR_GENERAL,
N_("`%s' invalid in 64-bit mode"), id);
- data[0] = (unsigned long)not64_insn;
+ data[0] = (uintptr_t)not64_insn;
data[1] = NELEMS(not64_insn);
data[2] = CPU_Not64;
data[3] = arch_x86->mode_bits;
return YASM_ARCH_NOTINSNPREFIX;
}
- data[0] = (unsigned long)pdata->group;
+ data[0] = (uintptr_t)pdata->group;
data[1] = pdata->data1;
data[2] = arch_x86->cpu_enabled;
data[3] = (((unsigned long)pdata->flags)<<8) | arch_x86->mode_bits;
}
yasm_arch_regtmod
-yasm_x86__parse_check_regtmod(yasm_arch *arch, unsigned long *data,
+yasm_x86__parse_check_regtmod(yasm_arch *arch, uintptr_t *data,
const char *id, size_t id_len)
{
yasm_arch_x86 *arch_x86 = (yasm_arch_x86 *)arch;
char *str_val;
yasm_intnum *intn;
yasm_floatnum *flt;
- unsigned long arch_data[4];
+ uintptr_t arch_data[4];
struct {
char *contents;
size_t len;
char *str_val;
yasm_intnum *intn;
yasm_floatnum *flt;
- unsigned long arch_data[4];
+ uintptr_t arch_data[4];
struct {
char *contents;
size_t len;
#include <string.h>
#include <assert.h>
+#include <libyasm-stdint.h>
+
#include <libyasm/coretype.h>
#ifdef lint