diff --git a/js/src/Makefile.in b/js/src/Makefile.in index 9a1d4b01569..715262e80b8 100644 --- a/js/src/Makefile.in +++ b/js/src/Makefile.in @@ -196,7 +196,6 @@ INSTALLED_HEADERS = \ jsscope.h \ jsscript.h \ jsstaticcheck.h \ - jsstddef.h \ jsstdint.h \ jsstr.h \ jstracer.h \ diff --git a/js/src/Makefile.ref b/js/src/Makefile.ref index 97803e9f9b0..022b6f17a8b 100644 --- a/js/src/Makefile.ref +++ b/js/src/Makefile.ref @@ -243,7 +243,6 @@ OTHER_HFILES = \ jscompat.h \ jscpucfg.h \ jsotypes.h \ - jsstddef.h \ prmjtime.h \ resource.h \ jsopcode.tbl \ diff --git a/js/src/jsapi.cpp b/js/src/jsapi.cpp index 5fee6d728bb..fce698e6582 100644 --- a/js/src/jsapi.cpp +++ b/js/src/jsapi.cpp @@ -41,7 +41,6 @@ /* * JavaScript API. */ -#include "jsstddef.h" #include #include #include @@ -5154,9 +5153,9 @@ JS_ExecuteScriptPart(JSContext *cx, JSObject *obj, JSScript *script, /* Make a temporary copy of the JSScript structure and farble it a bit. */ tmp = *script; if (part == JSEXEC_PROLOG) { - tmp.length = PTRDIFF(tmp.main, tmp.code, jsbytecode); + tmp.length = tmp.main - tmp.code; } else { - tmp.length -= PTRDIFF(tmp.main, tmp.code, jsbytecode); + tmp.length -= tmp.main - tmp.code; tmp.code = tmp.main; } diff --git a/js/src/jsarena.cpp b/js/src/jsarena.cpp index f6325528f25..3e597335117 100644 --- a/js/src/jsarena.cpp +++ b/js/src/jsarena.cpp @@ -42,7 +42,6 @@ * "Fast Allocation and Deallocation of Memory Based on Object Lifetimes" * David R. Hanson, Software -- Practice and Experience, Vol. 20(1). */ -#include "jsstddef.h" #include #include #include "jstypes.h" diff --git a/js/src/jsarray.cpp b/js/src/jsarray.cpp index 59f704667d8..70de3e8c4a7 100644 --- a/js/src/jsarray.cpp +++ b/js/src/jsarray.cpp @@ -75,7 +75,6 @@ * a js_SlowArrayClass, but have the same performance characteristics as * a dense array for slot accesses, at some cost in code complexity. */ -#include "jsstddef.h" #include #include #include "jstypes.h" diff --git a/js/src/jsatom.cpp b/js/src/jsatom.cpp index a11ba37af80..211e84f44d3 100644 --- a/js/src/jsatom.cpp +++ b/js/src/jsatom.cpp @@ -40,7 +40,6 @@ /* * JS atom table. */ -#include "jsstddef.h" #include #include #include "jstypes.h" diff --git a/js/src/jsbool.cpp b/js/src/jsbool.cpp index 3d9bdd66e4a..2ef409e65c9 100644 --- a/js/src/jsbool.cpp +++ b/js/src/jsbool.cpp @@ -40,7 +40,6 @@ /* * JS boolean implementation. */ -#include "jsstddef.h" #include "jstypes.h" #include "jsutil.h" /* Added by JSIFY */ #include "jsapi.h" diff --git a/js/src/jsbuiltins.cpp b/js/src/jsbuiltins.cpp index 1f3fcde631e..3da5898918c 100644 --- a/js/src/jsbuiltins.cpp +++ b/js/src/jsbuiltins.cpp @@ -39,7 +39,6 @@ * * ***** END LICENSE BLOCK ***** */ -#include "jsstddef.h" #include #include "jsapi.h" diff --git a/js/src/jscntxt.cpp b/js/src/jscntxt.cpp index d9a8d5ef49f..960bc3489a8 100644 --- a/js/src/jscntxt.cpp +++ b/js/src/jscntxt.cpp @@ -41,7 +41,6 @@ /* * JS execution context. */ -#include "jsstddef.h" #include #include #include diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp index 82cec7651d3..87f59f0b7f2 100644 --- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -51,7 +51,6 @@ * Frederick Brooks, 'The Second-System Effect'. */ -#include "jsstddef.h" #include #include #include diff --git a/js/src/jsdbgapi.cpp b/js/src/jsdbgapi.cpp index 5a5d9ffff6b..ecb1a7b1b75 100644 --- a/js/src/jsdbgapi.cpp +++ b/js/src/jsdbgapi.cpp @@ -41,7 +41,6 @@ /* * JS debugging API. */ -#include "jsstddef.h" #include #include "jstypes.h" #include "jsutil.h" /* Added by JSIFY */ diff --git a/js/src/jsdtoa.cpp b/js/src/jsdtoa.cpp index ca9176d4b0b..34959324c8b 100644 --- a/js/src/jsdtoa.cpp +++ b/js/src/jsdtoa.cpp @@ -40,7 +40,6 @@ /* * Portable double to alphanumeric string and back converters. */ -#include "jsstddef.h" #include "jslibmath.h" #include "jstypes.h" #include "jsdtoa.h" diff --git a/js/src/jsemit.cpp b/js/src/jsemit.cpp index 7d148c47572..bac3a1bc20d 100644 --- a/js/src/jsemit.cpp +++ b/js/src/jsemit.cpp @@ -41,7 +41,6 @@ /* * JS bytecode generation. */ -#include "jsstddef.h" #ifdef HAVE_MEMORY_H #include #endif @@ -126,7 +125,7 @@ EmitCheck(JSContext *cx, JSCodeGenerator *cg, JSOp op, ptrdiff_t delta) base = CG_BASE(cg); next = CG_NEXT(cg); limit = CG_LIMIT(cg); - offset = PTRDIFF(next, base, jsbytecode); + offset = next - base; if (next + delta > limit) { length = offset + delta; length = (length <= BYTECODE_CHUNK) @@ -136,7 +135,7 @@ EmitCheck(JSContext *cx, JSCodeGenerator *cg, JSOp op, ptrdiff_t delta) if (!base) { JS_ARENA_ALLOCATE_CAST(base, jsbytecode *, cg->codePool, incr); } else { - size = BYTECODE_SIZE(PTRDIFF(limit, base, jsbytecode)); + size = BYTECODE_SIZE(limit - base); incr -= size; JS_ARENA_GROW_CAST(base, jsbytecode *, cg->codePool, size, incr); } @@ -557,8 +556,8 @@ AddSpanDep(JSContext *cx, JSCodeGenerator *cg, jsbytecode *pc, jsbytecode *pc2, cg->numSpanDeps = index + 1; sd = cg->spanDeps + index; - sd->top = PTRDIFF(pc, CG_BASE(cg), jsbytecode); - sd->offset = sd->before = PTRDIFF(pc2, CG_BASE(cg), jsbytecode); + sd->top = pc - CG_BASE(cg); + sd->offset = sd->before = pc2 - CG_BASE(cg); if (js_CodeSpec[*pc].format & JOF_BACKPATCH) { /* Jump offset will be backpatched if off is a non-zero "bpdelta". */ @@ -673,7 +672,7 @@ GetSpanDep(JSCodeGenerator *cg, jsbytecode *pc) if (index != SPANDEP_INDEX_HUGE) return cg->spanDeps + index; - offset = PTRDIFF(pc, CG_BASE(cg), jsbytecode); + offset = pc - CG_BASE(cg); lo = 0; hi = cg->numSpanDeps - 1; while (lo <= hi) { @@ -910,7 +909,7 @@ OptimizeSpanDeps(JSContext *cx, JSCodeGenerator *cg) next = base + length; if (next > limit) { JS_ASSERT(length > BYTECODE_CHUNK); - size = BYTECODE_SIZE(PTRDIFF(limit, base, jsbytecode)); + size = BYTECODE_SIZE(limit - base); incr = BYTECODE_SIZE(length) - size; JS_ARENA_GROW_CAST(base, jsbytecode *, cg->codePool, size, incr); if (!base) { @@ -1429,7 +1428,7 @@ BackPatch(JSContext *cx, JSCodeGenerator *cg, ptrdiff_t last, stop = CG_CODE(cg, -1); while (pc != stop) { delta = GetJumpOffset(cg, pc); - span = PTRDIFF(target, pc, jsbytecode); + span = target - pc; CHECK_AND_SET_JUMP_OFFSET(cx, cg, pc, span); /* @@ -6670,7 +6669,7 @@ js_SetSrcNoteOffset(JSContext *cx, JSCodeGenerator *cg, uintN index, /* Maybe this offset was already set to a three-byte value. */ if (!(*sn & SN_3BYTE_OFFSET_FLAG)) { /* Losing, need to insert another two bytes for this offset. */ - index = PTRDIFF(sn, CG_NOTES(cg), jssrcnote); + index = sn - CG_NOTES(cg); /* * Simultaneously test to see if the source note array must grow to diff --git a/js/src/jsemit.h b/js/src/jsemit.h index 3cf7d45edd8..9b7cafeb2bf 100644 --- a/js/src/jsemit.h +++ b/js/src/jsemit.h @@ -43,8 +43,6 @@ /* * JS bytecode generation. */ - -#include "jsstddef.h" #include "jstypes.h" #include "jsatom.h" #include "jsopcode.h" @@ -379,7 +377,7 @@ struct JSCodeGenerator { #define CG_LIMIT(cg) ((cg)->current->limit) #define CG_NEXT(cg) ((cg)->current->next) #define CG_CODE(cg,offset) (CG_BASE(cg) + (offset)) -#define CG_OFFSET(cg) PTRDIFF(CG_NEXT(cg), CG_BASE(cg), jsbytecode) +#define CG_OFFSET(cg) (CG_NEXT(cg) - CG_BASE(cg)) #define CG_NOTES(cg) ((cg)->current->notes) #define CG_NOTE_COUNT(cg) ((cg)->current->noteCount) @@ -391,8 +389,7 @@ struct JSCodeGenerator { #define CG_PROLOG_LIMIT(cg) ((cg)->prolog.limit) #define CG_PROLOG_NEXT(cg) ((cg)->prolog.next) #define CG_PROLOG_CODE(cg,poff) (CG_PROLOG_BASE(cg) + (poff)) -#define CG_PROLOG_OFFSET(cg) PTRDIFF(CG_PROLOG_NEXT(cg), CG_PROLOG_BASE(cg),\ - jsbytecode) +#define CG_PROLOG_OFFSET(cg) (CG_PROLOG_NEXT(cg) - CG_PROLOG_BASE(cg)) #define CG_SWITCH_TO_MAIN(cg) ((cg)->current = &(cg)->main) #define CG_SWITCH_TO_PROLOG(cg) ((cg)->current = &(cg)->prolog) diff --git a/js/src/jsexn.cpp b/js/src/jsexn.cpp index 832b604da63..37e5c10b00f 100644 --- a/js/src/jsexn.cpp +++ b/js/src/jsexn.cpp @@ -42,7 +42,6 @@ * JS standard exception implementation. */ -#include "jsstddef.h" #include #include #include "jstypes.h" diff --git a/js/src/jsfile.cpp b/js/src/jsfile.cpp index 0211e3b298f..137f56cb7c3 100644 --- a/js/src/jsfile.cpp +++ b/js/src/jsfile.cpp @@ -43,7 +43,6 @@ */ #if JS_HAS_FILE_OBJECT -#include "jsstddef.h" #include "jsfile.h" /* ----------------- Platform-specific includes and defines ----------------- */ diff --git a/js/src/jsfun.cpp b/js/src/jsfun.cpp index e8d7e7d615a..660fc04f664 100644 --- a/js/src/jsfun.cpp +++ b/js/src/jsfun.cpp @@ -41,7 +41,6 @@ /* * JS function support. */ -#include "jsstddef.h" #include #include "jstypes.h" #include "jsbit.h" diff --git a/js/src/jsgc.cpp b/js/src/jsgc.cpp index dd9c88227e9..8316d77cc2f 100644 --- a/js/src/jsgc.cpp +++ b/js/src/jsgc.cpp @@ -48,7 +48,6 @@ * * XXX swizzle page to freelist for better locality of reference */ -#include "jsstddef.h" #include /* for free */ #include #include /* for memset used when DEBUG */ diff --git a/js/src/jshash.cpp b/js/src/jshash.cpp index 5fe5f7839c4..81df1ecba18 100644 --- a/js/src/jshash.cpp +++ b/js/src/jshash.cpp @@ -40,7 +40,6 @@ /* * PR hash table package. */ -#include "jsstddef.h" #include #include #include "jstypes.h" diff --git a/js/src/jsinterp.cpp b/js/src/jsinterp.cpp index 9093ac6c479..7abc53aaa07 100644 --- a/js/src/jsinterp.cpp +++ b/js/src/jsinterp.cpp @@ -41,7 +41,6 @@ /* * JavaScript bytecode interpreter. */ -#include "jsstddef.h" #include #include #include @@ -350,7 +349,7 @@ js_FullTestPropertyCache(JSContext *cx, jsbytecode *pc, entry->kshape, OBJ_SHAPE(obj)); js_Disassemble1(cx, cx->fp->script, pc, - PTRDIFF(pc, cx->fp->script->code, jsbytecode), + pc - cx->fp->script->code, JS_FALSE, stderr); #endif @@ -2060,7 +2059,7 @@ js_TraceOpcode(JSContext *cx, jsint len) fprintf(tracefp, "%4u: ", js_PCToLineNumber(cx, fp->script, fp->imacpc ? fp->imacpc : regs->pc)); js_Disassemble1(cx, fp->script, regs->pc, - PTRDIFF(regs->pc, fp->script->code, jsbytecode), + regs->pc - fp->script->code, JS_FALSE, tracefp); op = (JSOp) *regs->pc; nuses = js_CodeSpec[op].nuses; @@ -6351,14 +6350,14 @@ js_Interpret(JSContext *cx) BEGIN_CASE(JSOP_GOSUB) PUSH(JSVAL_FALSE); - i = PTRDIFF(regs.pc, script->main, jsbytecode) + JSOP_GOSUB_LENGTH; + i = (regs.pc - script->main) + JSOP_GOSUB_LENGTH; PUSH(INT_TO_JSVAL(i)); len = GET_JUMP_OFFSET(regs.pc); END_VARLEN_CASE BEGIN_CASE(JSOP_GOSUBX) PUSH(JSVAL_FALSE); - i = PTRDIFF(regs.pc, script->main, jsbytecode) + JSOP_GOSUBX_LENGTH; + i = (regs.pc - script->main) + JSOP_GOSUBX_LENGTH; len = GET_JUMPX_OFFSET(regs.pc); PUSH(INT_TO_JSVAL(i)); END_VARLEN_CASE diff --git a/js/src/jsiter.cpp b/js/src/jsiter.cpp index e2fdb7fa4ee..b7539a8f35a 100644 --- a/js/src/jsiter.cpp +++ b/js/src/jsiter.cpp @@ -41,7 +41,6 @@ /* * JavaScript iterators. */ -#include "jsstddef.h" #include /* for memcpy */ #include "jstypes.h" #include "jsutil.h" diff --git a/js/src/jskwgen.cpp b/js/src/jskwgen.cpp index 1d26c3dd304..1f68dc02b71 100644 --- a/js/src/jskwgen.cpp +++ b/js/src/jskwgen.cpp @@ -38,7 +38,7 @@ * * ***** END LICENSE BLOCK ***** */ -#include "jsstddef.h" +#include #include #include #include diff --git a/js/src/jslock.cpp b/js/src/jslock.cpp index 9f2a9369aa7..a71085bc600 100644 --- a/js/src/jslock.cpp +++ b/js/src/jslock.cpp @@ -42,7 +42,6 @@ /* * JS locking stubs. */ -#include "jsstddef.h" #include #include #include "jspubtd.h" diff --git a/js/src/jslog2.cpp b/js/src/jslog2.cpp index 84f4f51b412..a5e3e64fd80 100644 --- a/js/src/jslog2.cpp +++ b/js/src/jslog2.cpp @@ -36,7 +36,6 @@ * * ***** END LICENSE BLOCK ***** */ -#include "jsstddef.h" #include "jsbit.h" #include "jsutil.h" diff --git a/js/src/jsmath.cpp b/js/src/jsmath.cpp index 69f8e646d73..8c952de2b81 100644 --- a/js/src/jsmath.cpp +++ b/js/src/jsmath.cpp @@ -40,7 +40,6 @@ /* * JS math package. */ -#include "jsstddef.h" #include "jslibmath.h" #include #include "jstypes.h" diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index 11259a9b3cc..27ff56045ee 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -41,7 +41,6 @@ /* * JS number type and wrapper class. */ -#include "jsstddef.h" #if defined(XP_WIN) || defined(XP_OS2) #include #endif diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index 88b1c203871..59bc6423d14 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -41,7 +41,6 @@ /* * JS object implementation. */ -#include "jsstddef.h" #include #include #include "jstypes.h" diff --git a/js/src/jsopcode.cpp b/js/src/jsopcode.cpp index 51da1280b4a..0e4b571121f 100644 --- a/js/src/jsopcode.cpp +++ b/js/src/jsopcode.cpp @@ -41,7 +41,6 @@ /* * JS bytecode descriptors, disassemblers, and decompilers. */ -#include "jsstddef.h" #ifdef HAVE_MEMORY_H #include #endif @@ -235,7 +234,7 @@ js_Disassemble(JSContext *cx, JSScript *script, JSBool lines, FILE *fp) if (pc == script->main) fputs("main:\n", fp); len = js_Disassemble1(cx, script, pc, - PTRDIFF(pc, script->code, jsbytecode), + pc - script->code, lines, fp); if (!len) return JS_FALSE; @@ -618,7 +617,7 @@ QuoteString(Sprinter *sp, JSString *str, uint32 quote) if (t == z) break; } - len = PTRDIFF(t, s, jschar); + len = t - s; /* Allocate space for s, including the '\0' at the end. */ if (!SprintEnsureBuffer(sp, len)) @@ -2678,7 +2677,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) len = js_GetSrcNoteOffset(sn, 0); if (len) { - len -= PTRDIFF(pc, pc2, jsbytecode); + len -= pc - pc2; LOCAL_ASSERT_OUT(len > 0); js_printf(jp, " if "); ok = Decompile(ss, pc, len, JSOP_NOP) != NULL; @@ -3256,7 +3255,7 @@ Decompile(SprintStack *ss, jsbytecode *pc, intN nb, JSOp nextop) return NULL; done = pc + GetJumpOffset(pc, pc); pc += len; - len = PTRDIFF(done, pc, jsbytecode); + len = done - pc; if (!Decompile(ss, pc, len, op)) { JS_free(cx, (char *)lval); return NULL; @@ -5138,7 +5137,7 @@ DecompileExpression(JSContext *cx, JSScript *script, JSFunction *fun, break; default:; } - len = PTRDIFF(end, begin, jsbytecode); + len = end - begin; if (len <= 0) { name = FAILED_EXPRESSION_DECOMPILER; goto out; diff --git a/js/src/jsparse.cpp b/js/src/jsparse.cpp index aac60d34109..efe26a5db28 100644 --- a/js/src/jsparse.cpp +++ b/js/src/jsparse.cpp @@ -51,7 +51,6 @@ * * This parser attempts no error recovery. */ -#include "jsstddef.h" #include #include #include diff --git a/js/src/jsprf.cpp b/js/src/jsprf.cpp index 42857374f35..2634dd3b0af 100644 --- a/js/src/jsprf.cpp +++ b/js/src/jsprf.cpp @@ -41,7 +41,6 @@ ** ** Author: Kipp E.B. Hickman */ -#include "jsstddef.h" #include #include #include diff --git a/js/src/jsregexp.cpp b/js/src/jsregexp.cpp index 56409007700..24f836ad770 100644 --- a/js/src/jsregexp.cpp +++ b/js/src/jsregexp.cpp @@ -41,7 +41,6 @@ /* * JS regular expressions, after Perl. */ -#include "jsstddef.h" #include #include #include diff --git a/js/src/jsscan.cpp b/js/src/jsscan.cpp index a1592e46f8e..80725ca0c71 100644 --- a/js/src/jsscan.cpp +++ b/js/src/jsscan.cpp @@ -41,7 +41,6 @@ /* * JS lexical scanner. */ -#include "jsstddef.h" #include /* first to avoid trouble on some systems */ #include #include @@ -186,14 +185,14 @@ GrowTokenBuf(JSStringBuffer *sb, size_t newlength) cx = (JSContext*) sb->data; base = sb->base; - offset = PTRDIFF(sb->ptr, base, jschar); + offset = sb->ptr - base; pool = &cx->tempPool; if (!base) { tbsize = TBMIN * sizeof(jschar); length = TBMIN - 1; JS_ARENA_ALLOCATE_CAST(base, jschar *, pool, tbsize); } else { - length = PTRDIFF(sb->limit, base, jschar); + length = sb->limit - base; if ((size_t)length >= ~(size_t)0 / sizeof(jschar)) { base = NULL; } else { @@ -300,7 +299,7 @@ GetChar(JSTokenStream *ts) c = ts->ungetbuf[--ts->ungetpos]; } else { if (ts->linebuf.ptr == ts->linebuf.limit) { - len = PTRDIFF(ts->userbuf.limit, ts->userbuf.ptr, jschar); + len = ts->userbuf.limit - ts->userbuf.ptr; if (len <= 0) { if (!ts->file) { ts->flags |= TSF_EOF; @@ -366,7 +365,7 @@ GetChar(JSTokenStream *ts) * Else copy JS_LINE_LIMIT-1 bytes into linebuf. */ if (nl < ts->userbuf.limit) - len = PTRDIFF(nl, ts->userbuf.ptr, jschar) + 1; + len = (nl - ts->userbuf.ptr) + 1; if (len >= JS_LINE_LIMIT) { len = JS_LINE_LIMIT - 1; ts->saveEOL = nl; @@ -559,7 +558,7 @@ js_ReportCompileErrorNumber(JSContext *cx, JSTokenStream *ts, JSParseNode *pn, tp = &ts->tokens[ts->cursor].pos; } report.lineno = ts->lineno; - linelength = PTRDIFF(ts->linebuf.limit, ts->linebuf.base, jschar); + linelength = ts->linebuf.limit - ts->linebuf.base; linechars = (jschar *)JS_malloc(cx, (linelength + 1) * sizeof(jschar)); if (!linechars) { warning = JS_FALSE; @@ -680,7 +679,7 @@ GrowStringBuffer(JSStringBuffer *sb, size_t newlength) ptrdiff_t offset; jschar *bp; - offset = PTRDIFF(sb->ptr, sb->base, jschar); + offset = sb->ptr - sb->base; JS_ASSERT(offset >= 0); newlength += offset + 1; if ((size_t)offset < newlength && newlength < ~(size_t)0 / sizeof(jschar)) @@ -816,7 +815,7 @@ GetXMLEntity(JSContext *cx, JSTokenStream *ts) JSErrNum msg; /* Put the entity, including the '&' already scanned, in ts->tokenbuf. */ - offset = PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar); + offset = ts->tokenbuf.ptr - ts->tokenbuf.base; FastAppendChar(&ts->tokenbuf, '&'); if (!STRING_BUFFER_OK(&ts->tokenbuf)) return JS_FALSE; @@ -832,7 +831,7 @@ GetXMLEntity(JSContext *cx, JSTokenStream *ts) } /* Let length be the number of jschars after the '&', including the ';'. */ - length = PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar) - offset; + length = (ts->tokenbuf.ptr - ts->tokenbuf.base) - offset; bp = ts->tokenbuf.base + offset; c = d = 0; ispair = JS_FALSE; @@ -915,9 +914,9 @@ badncr: bad: /* No match: throw a TypeError per ECMA-357 10.3.2.1 step 8(a). */ JS_ASSERT(STRING_BUFFER_OK(&ts->tokenbuf)); - JS_ASSERT(PTRDIFF(ts->tokenbuf.ptr, bp, jschar) >= 1); + JS_ASSERT((ts->tokenbuf.ptr - bp) >= 1); bytes = js_DeflateString(cx, bp + 1, - PTRDIFF(ts->tokenbuf.ptr, bp, jschar) - 1); + (ts->tokenbuf.ptr - bp) - 1); if (bytes) { js_ReportCompileErrorNumber(cx, ts, NULL, JSREPORT_ERROR, msg, bytes); @@ -989,7 +988,7 @@ NewToken(JSTokenStream *ts, ptrdiff_t adjust) tp = &CURRENT_TOKEN(ts); tp->ptr = ts->linebuf.ptr + adjust; tp->pos.begin.index = ts->linepos + - PTRDIFF(tp->ptr, ts->linebuf.base, jschar) - + (tp->ptr - ts->linebuf.base) - ts->ungetpos; tp->pos.begin.lineno = tp->pos.end.lineno = (uint16)ts->lineno; return tp; @@ -1020,7 +1019,7 @@ js_GetToken(JSContext *cx, JSTokenStream *ts) #endif #define INIT_TOKENBUF() (ts->tokenbuf.ptr = ts->tokenbuf.base) -#define TOKENBUF_LENGTH() PTRDIFF(ts->tokenbuf.ptr, ts->tokenbuf.base, jschar) +#define TOKENBUF_LENGTH() (ts->tokenbuf.ptr - ts->tokenbuf.base) #define TOKENBUF_OK() STRING_BUFFER_OK(&ts->tokenbuf) #define TOKENBUF_TO_ATOM() (TOKENBUF_OK() \ ? js_AtomizeChars(cx, \ @@ -1986,7 +1985,7 @@ eol_out: tt = TOK_ERROR; JS_ASSERT(tt < TOK_LIMIT); tp->pos.end.index = ts->linepos + - PTRDIFF(ts->linebuf.ptr, ts->linebuf.base, jschar) - + (ts->linebuf.ptr - ts->linebuf.base) - ts->ungetpos; tp->type = tt; return tt; diff --git a/js/src/jsscope.cpp b/js/src/jsscope.cpp index 891a23a9685..f00620d18a8 100644 --- a/js/src/jsscope.cpp +++ b/js/src/jsscope.cpp @@ -41,7 +41,6 @@ /* * JS symbol tables. */ -#include "jsstddef.h" #include #include #include "jstypes.h" diff --git a/js/src/jsscript.cpp b/js/src/jsscript.cpp index 557f937ac7c..06a361cea66 100644 --- a/js/src/jsscript.cpp +++ b/js/src/jsscript.cpp @@ -41,7 +41,6 @@ /* * JS script operations. */ -#include "jsstddef.h" #include #include "jstypes.h" #include "jsutil.h" /* Added by JSIFY */ @@ -453,7 +452,7 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic) if (xdr->mode == JSXDR_ENCODE) { length = script->length; - prologLength = PTRDIFF(script->main, script->code, jsbytecode); + prologLength = script->main - script->code; JS_ASSERT((int16)script->version != JSVERSION_UNKNOWN); version = (uint32)script->version | (script->nfixed << 16); lineno = (uint32)script->lineno; @@ -465,7 +464,7 @@ js_XDRScript(JSXDRState *xdr, JSScript **scriptp, JSBool *hasMagic) notes = SCRIPT_NOTES(script); for (sn = notes; !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) continue; - nsrcnotes = PTRDIFF(sn, notes, jssrcnote); + nsrcnotes = sn - notes; nsrcnotes++; /* room for the terminator */ if (script->objectsOffset != 0) @@ -1687,7 +1686,7 @@ js_GetSrcNoteCached(JSContext *cx, JSScript *script, jsbytecode *pc) uintN nsrcnotes; - target = PTRDIFF(pc, script->code, jsbytecode); + target = pc - script->code; if ((uint32)target >= script->length) return NULL; @@ -1784,7 +1783,7 @@ js_PCToLineNumber(JSContext *cx, JSScript *script, jsbytecode *pc) */ lineno = script->lineno; offset = 0; - target = PTRDIFF(pc, script->code, jsbytecode); + target = pc - script->code; for (sn = SCRIPT_NOTES(script); !SN_IS_TERMINATOR(sn); sn = SN_NEXT(sn)) { offset += SN_DELTA(sn); type = (JSSrcNoteType) SN_TYPE(sn); diff --git a/js/src/jsstddef.h b/js/src/jsstddef.h deleted file mode 100644 index 45b417fc0f4..00000000000 --- a/js/src/jsstddef.h +++ /dev/null @@ -1,87 +0,0 @@ -/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- - * - * ***** BEGIN LICENSE BLOCK ***** - * Version: MPL 1.1/GPL 2.0/LGPL 2.1 - * - * The contents of this file are subject to the Mozilla Public License Version - * 1.1 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * http://www.mozilla.org/MPL/ - * - * Software distributed under the License is distributed on an "AS IS" basis, - * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License - * for the specific language governing rights and limitations under the - * License. - * - * The Original Code is Mozilla Communicator client code, released - * March 31, 1998. - * - * The Initial Developer of the Original Code is - * Netscape Communications Corporation. - * Portions created by the Initial Developer are Copyright (C) 1998 - * the Initial Developer. All Rights Reserved. - * - * Contributor(s): - * - * Alternatively, the contents of this file may be used under the terms of - * either of the GNU General Public License Version 2 or later (the "GPL"), - * or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), - * in which case the provisions of the GPL or the LGPL are applicable instead - * of those above. If you wish to allow use of your version of this file only - * under the terms of either the GPL or the LGPL, and not to allow others to - * use your version of this file under the terms of the MPL, indicate your - * decision by deleting the provisions above and replace them with the notice - * and other provisions required by the GPL or the LGPL. If you do not delete - * the provisions above, a recipient may use your version of this file under - * the terms of any one of the MPL, the GPL or the LGPL. - * - * ***** END LICENSE BLOCK ***** */ - -/* - * stddef inclusion here to first declare ptrdif as a signed long instead of a - * signed int. - */ - -#ifdef _WINDOWS -# ifndef XP_WIN -# define XP_WIN -# endif -#if defined(_WIN32) || defined(WIN32) -# ifndef XP_WIN32 -# define XP_WIN32 -# endif -#else -# ifndef XP_WIN16 -# define XP_WIN16 -# endif -#endif -#endif - -#ifdef XP_WIN16 -#ifndef _PTRDIFF_T_DEFINED -typedef long ptrdiff_t; - -/* - * The Win16 compiler treats pointer differences as 16-bit signed values. - * This macro allows us to treat them as 17-bit signed values, stored in - * a 32-bit type. - */ -#define PTRDIFF(p1, p2, type) \ - ((((unsigned long)(p1)) - ((unsigned long)(p2))) / sizeof(type)) - -#define _PTRDIFF_T_DEFINED -#endif /*_PTRDIFF_T_DEFINED*/ -#else /*WIN16*/ - -#define PTRDIFF(p1, p2, type) \ - ((p1) - (p2)) - -#endif - -#include - -#ifdef __cplusplus -# define __cplusplus_only(x) x -#else -# define __cplusplus_only(x) /* nothing */ -#endif diff --git a/js/src/jsstr.cpp b/js/src/jsstr.cpp index 0d08df7b055..1125f4edd0c 100644 --- a/js/src/jsstr.cpp +++ b/js/src/jsstr.cpp @@ -48,7 +48,6 @@ * of rooting things that might lose their newborn root due to subsequent GC * allocations in the same native method. */ -#include "jsstddef.h" #include #include #include "jstypes.h" diff --git a/js/src/jstracer.cpp b/js/src/jstracer.cpp index eef3de2cbcc..9ed2166a0d4 100644 --- a/js/src/jstracer.cpp +++ b/js/src/jstracer.cpp @@ -39,7 +39,6 @@ * * ***** END LICENSE BLOCK ***** */ -#include "jsstddef.h" // always first #include "jsbit.h" // low-level (NSPR-based) headers next #include "jsprf.h" #include // standard headers next @@ -4328,9 +4327,7 @@ TraceRecorder::monitorRecording(JSContext* cx, TraceRecorder* tr, JSOp op) js_Disassemble1(cx, cx->fp->script, cx->fp->regs->pc, \ (cx->fp->imacpc) \ ? 0 \ - : PTRDIFF(cx->fp->regs->pc, \ - cx->fp->script->code, \ - jsbytecode), \ + : cx->fp->regs->pc - cx->fp->script->code, \ !cx->fp->imacpc, stdout);) \ flag = tr->record_##x(); \ if (x == JSOP_ITER || x == JSOP_NEXTITER || x == JSOP_APPLY || \ diff --git a/js/src/jstracer.h b/js/src/jstracer.h index ae25f4fab60..82926c7277b 100644 --- a/js/src/jstracer.h +++ b/js/src/jstracer.h @@ -45,7 +45,6 @@ #ifdef JS_TRACER #include "jscntxt.h" -#include "jsstddef.h" #include "jstypes.h" #include "jslock.h" #include "jsnum.h" diff --git a/js/src/jsutil.cpp b/js/src/jsutil.cpp index 4b0a0aa6861..52d68ada617 100644 --- a/js/src/jsutil.cpp +++ b/js/src/jsutil.cpp @@ -41,7 +41,6 @@ /* * PR assertion checker. */ -#include "jsstddef.h" #include #include #include "jstypes.h" diff --git a/js/src/jsxdrapi.cpp b/js/src/jsxdrapi.cpp index 5643e739655..0735fd1c34f 100644 --- a/js/src/jsxdrapi.cpp +++ b/js/src/jsxdrapi.cpp @@ -36,7 +36,6 @@ * the terms of any one of the MPL, the GPL or the LGPL. * * ***** END LICENSE BLOCK ***** */ -#include "jsstddef.h" #include "jsversion.h" #if JS_HAS_XDR diff --git a/js/src/jsxml.cpp b/js/src/jsxml.cpp index 9027340497b..717689128d9 100644 --- a/js/src/jsxml.cpp +++ b/js/src/jsxml.cpp @@ -37,7 +37,6 @@ * * ***** END LICENSE BLOCK ***** */ -#include "jsstddef.h" #include "jsversion.h" #if JS_HAS_XML_SUPPORT @@ -1279,7 +1278,7 @@ ParseNodeToQName(JSContext *cx, JSParseContext *pc, JSParseNode *pn, limit = start + length; colon = js_strchr_limit(start, ':', limit); if (colon) { - offset = PTRDIFF(colon, start, jschar); + offset = colon - start; prefix = js_NewDependentString(cx, str, 0, offset); if (!prefix) return NULL; @@ -1371,10 +1370,10 @@ ChompXMLWhitespace(JSContext *cx, JSString *str) break; --end; } - newlength = PTRDIFF(end, cp, jschar); + newlength = end - cp; if (newlength == length) return str; - offset = PTRDIFF(cp, start, jschar); + offset = cp - start; return js_NewDependentString(cx, str, offset, newlength); } @@ -2460,13 +2459,13 @@ GeneratePrefix(JSContext *cx, JSString *uri, JSXMLArray *decls) while (--cp > start) { if (*cp == '.' || *cp == '/' || *cp == ':') { ++cp; - length = PTRDIFF(end, cp, jschar); + length = end - cp; if (IsXMLName(cp, length) && !STARTS_WITH_XML(cp, length)) break; end = --cp; } } - length = PTRDIFF(end, cp, jschar); + length = end - cp; /* * If the namespace consisted only of non-XML names or names that begin @@ -2527,7 +2526,7 @@ GeneratePrefix(JSContext *cx, JSString *uri, JSXMLArray *decls) } while (!done); if (bp == cp) { - offset = PTRDIFF(cp, start, jschar); + offset = cp - start; prefix = js_NewDependentString(cx, uri, offset, length); } else { prefix = js_NewString(cx, bp, newlength); diff --git a/js/src/jsxml.h b/js/src/jsxml.h index 6952efce950..b2a988834cf 100644 --- a/js/src/jsxml.h +++ b/js/src/jsxml.h @@ -39,7 +39,6 @@ #ifndef jsxml_h___ #define jsxml_h___ -#include "jsstddef.h" #include "jspubtd.h" JS_BEGIN_EXTERN_C diff --git a/js/src/prmjtime.cpp b/js/src/prmjtime.cpp index 3a01b07721f..64049f901ab 100644 --- a/js/src/prmjtime.cpp +++ b/js/src/prmjtime.cpp @@ -40,7 +40,6 @@ /* * PR time code. */ -#include "jsstddef.h" #ifdef SOLARIS #define _REENTRANT 1 #endif diff --git a/js/src/shell/js.cpp b/js/src/shell/js.cpp index 5e437d32bd2..34615780227 100644 --- a/js/src/shell/js.cpp +++ b/js/src/shell/js.cpp @@ -41,7 +41,6 @@ /* * JS shell. */ -#include "jsstddef.h" #include #include #include @@ -1377,7 +1376,7 @@ LineToPC(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, jsval *rval) pc = JS_LineNumberToPC(cx, script, lineno); if (!pc) return JS_FALSE; - *rval = INT_TO_JSVAL(PTRDIFF(pc, script->code, jsbytecode)); + *rval = INT_TO_JSVAL(pc - script->code); return JS_TRUE; } @@ -1476,7 +1475,7 @@ SrcNotes(JSContext *cx, JSScript *script) } } fprintf(gOutFile, "%3u: %5u [%4u] %-8s", - (uintN) PTRDIFF(sn, notes, jssrcnote), offset, delta, name); + (uintN) (sn - notes), offset, delta, name); switch (type) { case SRC_SETLINE: fprintf(gOutFile, " lineno %u", (uintN) js_GetSrcNoteOffset(sn, 0)); @@ -1746,7 +1745,7 @@ DisassWithSrc(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, } len = js_Disassemble1(cx, script, pc, - PTRDIFF(pc, script->code, jsbytecode), + pc - script->code, JS_TRUE, stdout); if (!len) { ok = JS_FALSE; @@ -3967,7 +3966,7 @@ my_ErrorReporter(JSContext *cx, const char *message, JSErrorReport *report) report->linebuf, (n > 0 && report->linebuf[n-1] == '\n') ? "" : "\n", prefix); - n = PTRDIFF(report->tokenptr, report->linebuf, char); + n = report->tokenptr - report->linebuf; for (i = j = 0; i < n; i++) { if (report->linebuf[i] == '\t') { for (k = (j + 8) & ~7; j < k; j++) {